| 14485 | */ |
| 14486 | template<typename BasicJsonType> |
| 14487 | static BasicJsonType |
| 14488 | unflatten(const BasicJsonType& value) |
| 14489 | { |
| 14490 | if (JSON_HEDLEY_UNLIKELY(!value.is_object())) |
| 14491 | { |
| 14492 | JSON_THROW(detail::type_error::create(314, "only objects can be unflattened", &value)); |
| 14493 | } |
| 14494 | |
| 14495 | BasicJsonType result; |
| 14496 | |
| 14497 | // iterate the JSON object values |
| 14498 | for (const auto& element : *value.m_value.object) |
| 14499 | { |
| 14500 | if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive())) |
| 14501 | { |
| 14502 | JSON_THROW(detail::type_error::create(315, "values in object must be primitive", &element.second)); |
| 14503 | } |
| 14504 | |
| 14505 | // assign value to reference pointed to by JSON pointer; Note that if |
| 14506 | // the JSON pointer is "" (i.e., points to the whole value), function |
| 14507 | // get_and_create returns a reference to result itself. An assignment |
| 14508 | // will then create a primitive value. |
| 14509 | json_pointer(element.first).get_and_create(result) = element.second; |
| 14510 | } |
| 14511 | |
| 14512 | return result; |
| 14513 | } |
| 14514 | |
| 14515 | // can't use conversion operator because of ambiguity |
| 14516 | json_pointer<string_t> convert() const& |
nothing calls this directly
no test coverage detected