Skip to content

Commit

Permalink
🎉 first draft for #661
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Aug 2, 2017
1 parent 0ea0d7d commit d1e13d5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12066,6 +12066,31 @@ class basic_json
m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
}

void update(const_reference j)
{
// implicitly convert null value to an empty object
if (is_null())
{
m_type = value_t::object;
m_value.object = create<object_t>();
assert_invariant();
}

if (JSON_UNLIKELY(not is_object()))
{
JSON_THROW(type_error::create(305, "cannot use merge with " + type_name()));
}
if (JSON_UNLIKELY(not j.is_object()))
{
JSON_THROW(type_error::create(305, "cannot use merge with " + j.type_name()));
}

for (auto it = j.begin(); it != j.end(); ++it)
{
m_value.object->emplace(it.key(), it.value());
}
}

/*!
@brief exchanges the values
Expand Down

0 comments on commit d1e13d5

Please sign in to comment.