MCPcopy Create free account
hub / github.com/arun11299/cpp-jwt / unflatten

Function unflatten

include/jwt/json/json.hpp:12446–12472  ·  view source on GitHub ↗

! @param[in] value flattened JSON @return unflattened JSON @throw parse_error.109 if array index is not a number @throw type_error.314 if value is not an object @throw type_error.315 if object values are not primitive @throw type_error.313 if value cannot be unflattened */

Source from the content-addressed store, hash-verified

12444 @throw type_error.313 if value cannot be unflattened
12445 */
12446 static BasicJsonType
12447 unflatten(const BasicJsonType& value)
12448 {
12449 if (JSON_HEDLEY_UNLIKELY(!value.is_object()))
12450 {
12451 JSON_THROW(detail::type_error::create(314, "only objects can be unflattened"));
12452 }
12453
12454 BasicJsonType result;
12455
12456 // iterate the JSON object values
12457 for (const auto& element : *value.m_value.object)
12458 {
12459 if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive()))
12460 {
12461 JSON_THROW(detail::type_error::create(315, "values in object must be primitive"));
12462 }
12463
12464 // assign value to reference pointed to by JSON pointer; Note that if
12465 // the JSON pointer is "" (i.e., points to the whole value), function
12466 // get_and_create returns a reference to result itself. An assignment
12467 // will then create a primitive value.
12468 json_pointer(element.first).get_and_create(result) = element.second;
12469 }
12470
12471 return result;
12472 }
12473
12474 /*!
12475 @brief compares two JSON pointers for equality

Callers

nothing calls this directly

Calls 2

createFunction · 0.85
json_pointerClass · 0.85

Tested by

no test coverage detected