MCPcopy Create free account
hub / github.com/MITK/MITK / JsonValueToFilterString

Function JsonValueToFilterString

Modules/RESTAPI/src/mitkDataStorageBridge.cpp:41–56  ·  view source on GitHub ↗

* @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 */

Source from the content-addressed store, hash-verified

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)

Callers 1

BuildNodePredicateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected