MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / unflatten

Function unflatten

3rd/nlohmann_json/single_include/nlohmann/json.hpp:13379–13405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13377 @throw type_error.313 if value cannot be unflattened
13378 */
13379 static BasicJsonType
13380 unflatten(const BasicJsonType& value)
13381 {
13382 if (JSON_HEDLEY_UNLIKELY(!value.is_object()))
13383 {
13384 JSON_THROW(detail::type_error::create(314, "only objects can be unflattened", value));
13385 }
13386
13387 BasicJsonType result;
13388
13389 // iterate the JSON object values
13390 for (const auto& element : *value.m_value.object)
13391 {
13392 if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive()))
13393 {
13394 JSON_THROW(detail::type_error::create(315, "values in object must be primitive", element.second));
13395 }
13396
13397 // assign value to reference pointed to by JSON pointer; Note that if
13398 // the JSON pointer is "" (i.e., points to the whole value), function
13399 // get_and_create returns a reference to result itself. An assignment
13400 // will then create a primitive value.
13401 json_pointer(element.first).get_and_create(result) = element.second;
13402 }
13403
13404 return result;
13405 }
13406
13407 /*!
13408 @brief compares two JSON pointers for equality

Callers

nothing calls this directly

Calls 2

createFunction · 0.70
json_pointerClass · 0.70

Tested by

no test coverage detected