1
0
mirror of https://github.com/nlohmann/json synced 2024-11-26 13:50:07 +00:00

🔨 cleanup

This commit is contained in:
Niels Lohmann 2018-03-17 23:31:18 +01:00
parent 606a25195f
commit 375b05a17d
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69
2 changed files with 32 additions and 20 deletions

View File

@ -277,17 +277,23 @@ class json_sax_dom_parser : public json_sax<BasicJsonType>
}
else
{
assert(ref_stack.back()->is_array() or ref_stack.back()->is_object());
if (ref_stack.back()->is_array())
switch (ref_stack.back()->m_type)
{
ref_stack.back()->m_value.array->push_back(BasicJsonType(std::forward<Value>(v)));
return &(ref_stack.back()->m_value.array->back());
}
else
{
assert(object_element);
*object_element = BasicJsonType(std::forward<Value>(v));
return object_element;
case value_t::array:
{
ref_stack.back()->m_value.array->push_back(BasicJsonType(std::forward<Value>(v)));
return &(ref_stack.back()->m_value.array->back());
}
case value_t::object:
{
assert(object_element);
*object_element = BasicJsonType(std::forward<Value>(v));
return object_element;
}
default:
assert(false); // LCOV_EXCL_LINE
}
}
}

View File

@ -3413,17 +3413,23 @@ class json_sax_dom_parser : public json_sax<BasicJsonType>
}
else
{
assert(ref_stack.back()->is_array() or ref_stack.back()->is_object());
if (ref_stack.back()->is_array())
switch (ref_stack.back()->m_type)
{
ref_stack.back()->m_value.array->push_back(BasicJsonType(std::forward<Value>(v)));
return &(ref_stack.back()->m_value.array->back());
}
else
{
assert(object_element);
*object_element = BasicJsonType(std::forward<Value>(v));
return object_element;
case value_t::array:
{
ref_stack.back()->m_value.array->push_back(BasicJsonType(std::forward<Value>(v)));
return &(ref_stack.back()->m_value.array->back());
}
case value_t::object:
{
assert(object_element);
*object_element = BasicJsonType(std::forward<Value>(v));
return object_element;
}
default:
assert(false); // LCOV_EXCL_LINE
}
}
}