MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / unflatten

Function unflatten

include/behaviortree_cpp/contrib/json.hpp:14611–14637  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14609 */
14610 template<typename BasicJsonType>
14611 static BasicJsonType
14612 unflatten(const BasicJsonType& value)
14613 {
14614 if (JSON_HEDLEY_UNLIKELY(!value.is_object()))
14615 {
14616 JSON_THROW(detail::type_error::create(314, "only objects can be unflattened", &value));
14617 }
14618
14619 BasicJsonType result;
14620
14621 // iterate the JSON object values
14622 for (const auto& element : *value.m_data.m_value.object)
14623 {
14624 if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive()))
14625 {
14626 JSON_THROW(detail::type_error::create(315, "values in object must be primitive", &element.second));
14627 }
14628
14629 // assign value to reference pointed to by JSON pointer; Note that if
14630 // the JSON pointer is "" (i.e., points to the whole value), function
14631 // get_and_create returns a reference to result itself. An assignment
14632 // will then create a primitive value.
14633 json_pointer(element.first).get_and_create(result) = element.second;
14634 }
14635
14636 return result;
14637 }
14638
14639 // can't use conversion operator because of ambiguity
14640 json_pointer<string_t> convert() const&

Callers

nothing calls this directly

Calls 2

createFunction · 0.85
json_pointerFunction · 0.70

Tested by

no test coverage detected