| 14523 | */ |
| 14524 | template<typename BasicJsonType> |
| 14525 | static BasicJsonType |
| 14526 | unflatten(const BasicJsonType& value) |
| 14527 | { |
| 14528 | if (JSON_HEDLEY_UNLIKELY(!value.is_object())) |
| 14529 | { |
| 14530 | JSON_THROW(detail::type_error::create(314, "only objects can be unflattened", &value)); |
| 14531 | } |
| 14532 | |
| 14533 | BasicJsonType result; |
| 14534 | |
| 14535 | // iterate the JSON object values |
| 14536 | for (const auto& element : *value.m_value.object) |
| 14537 | { |
| 14538 | if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive())) |
| 14539 | { |
| 14540 | JSON_THROW(detail::type_error::create(315, "values in object must be primitive", &element.second)); |
| 14541 | } |
| 14542 | |
| 14543 | // assign value to reference pointed to by JSON pointer; Note that if |
| 14544 | // the JSON pointer is "" (i.e., points to the whole value), function |
| 14545 | // get_and_create returns a reference to result itself. An assignment |
| 14546 | // will then create a primitive value. |
| 14547 | json_pointer(element.first).get_and_create(result) = element.second; |
| 14548 | } |
| 14549 | |
| 14550 | return result; |
| 14551 | } |
| 14552 | |
| 14553 | // can't use conversion operator because of ambiguity |
| 14554 | json_pointer<string_t> convert() const& |
nothing calls this directly
no test coverage detected