MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / update

Function update

3rd/nlohmann_json/single_include/nlohmann/json.hpp:23501–23527  ·  view source on GitHub ↗

! @brief updates a JSON object from another object, overwriting existing keys Inserts all values from JSON object @a j and overwrites existing keys. @param[in] j JSON object to read values from @throw type_error.312 if called on JSON values other than objects; example: `"cannot use update() with string"` @complexity O(N*log(size() + N)), where N is the number of elemen

Source from the content-addressed store, hash-verified

23499 @since version 3.0.0
23500 */
23501 void update(const_reference j)
23502 {
23503 // implicitly convert null value to an empty object
23504 if (is_null())
23505 {
23506 m_type = value_t::object;
23507 m_value.object = create<object_t>();
23508 assert_invariant();
23509 }
23510
23511 if (JSON_HEDLEY_UNLIKELY(!is_object()))
23512 {
23513 JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()), *this));
23514 }
23515 if (JSON_HEDLEY_UNLIKELY(!j.is_object()))
23516 {
23517 JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name()), *this));
23518 }
23519
23520 for (auto it = j.cbegin(); it != j.cend(); ++it)
23521 {
23522 m_value.object->operator[](it.key()) = it.value();
23523#if JSON_DIAGNOSTICS
23524 m_value.object->operator[](it.key()).m_parent = this;
23525#endif
23526 }
23527 }
23528
23529 /*!
23530 @brief updates a JSON object from another object, overwriting existing keys

Callers

nothing calls this directly

Calls 10

stringFunction · 0.85
is_nullFunction · 0.70
is_objectFunction · 0.70
createFunction · 0.70
type_nameFunction · 0.70
cbeginMethod · 0.45
cendMethod · 0.45
operator[]Method · 0.45
keyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected