* @brief Convert a JSON value to its string representation for filtering. * * Needed to ensure that strings are returned w/o '\"' escapes and null is converted into empty string. * - JSON string -> the string value * - JSON null -> empty string * - JSON boolean, number and object/array -> dump() representation */
| 39 | * - JSON boolean, number and object/array -> dump() representation |
| 40 | */ |
| 41 | std::string JsonValueToFilterString(const nlohmann::json& json) |
| 42 | { |
| 43 | if (json.is_string()) |
| 44 | { |
| 45 | return json.get<std::string>(); |
| 46 | } |
| 47 | else if (json.is_null()) |
| 48 | { |
| 49 | return ""; |
| 50 | } |
| 51 | else |
| 52 | { |
| 53 | // For boolean, numbers and complex types (arrays, objects), use the JSON dump |
| 54 | return json.dump(); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | mitk::BaseProperty::ConstPointer GetConstProperty(const mitk::DataNode* node, const std::string& propertyKey, |
| 59 | const std::optional<std::string>& context, const mitk::PropertyScope scope) |