* 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
| 395 | * @return The parsed value. |
| 396 | */ |
| 397 | Value 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 | |
| 408 | inline |
| 409 | bool JsonSax::null() |