MCPcopy Create free account
hub / github.com/Icinga/icinga2 / JsonDecode

Method JsonDecode

lib/base/json.cpp:397–406  ·  view source on GitHub ↗

* Parses a JSON string into the Icinga Value type. * * A depth limit can be provided. Both JSON arrays (mapped to icinga::Array) and JSON objects * (mapped to icinga::Dictionary) count towards that limit. A limit of 1 means, that the outer object can be an array * or object, but it can only contain scalar values. * * @param data The JSON to be parsed (throws if the JSON is invalid). * @para

Source from the content-addressed store, hash-verified

395 * @return The parsed value.
396 */
397Value icinga::JsonDecode(const String& data, size_t depthLimit)
398{
399 String sanitized (Utility::ValidateUTF8(data));
400
401 JsonSax stateMachine{depthLimit};
402
403 nlohmann::json::sax_parse(sanitized.Begin(), sanitized.End(), &stateMachine);
404
405 return stateMachine.GetResult();
406}
407
408inline
409bool JsonSax::null()

Callers

nothing calls this directly

Calls 4

sax_parseFunction · 0.85
GetResultMethod · 0.80
BeginMethod · 0.45
EndMethod · 0.45

Tested by

no test coverage detected