MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / update

Function update

external/json/json.hpp:17509–17532  ·  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

17507 @since version 3.0.0
17508 */
17509 void update(const_reference j)
17510 {
17511 // implicitly convert null value to an empty object
17512 if (is_null())
17513 {
17514 m_type = value_t::object;
17515 m_value.object = create<object_t>();
17516 assert_invariant();
17517 }
17518
17519 if (JSON_UNLIKELY(not is_object()))
17520 {
17521 JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name())));
17522 }
17523 if (JSON_UNLIKELY(not j.is_object()))
17524 {
17525 JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name())));
17526 }
17527
17528 for (auto it = j.cbegin(); it != j.cend(); ++it)
17529 {
17530 m_value.object->operator[](it.key()) = it.value();
17531 }
17532 }
17533
17534 /*!
17535 @brief updates a JSON object from another object, overwriting existing keys

Callers

nothing calls this directly

Calls 8

is_nullFunction · 0.85
assert_invariantFunction · 0.85
is_objectFunction · 0.85
createFunction · 0.85
type_nameFunction · 0.85
operator[]Method · 0.45
keyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected