MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / update

Function update

Source/Utils/json.hpp:22256–22279  ·  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

Source from the content-addressed store, hash-verified

22254 @since version 3.0.0
22255 */
22256 void update(const_reference j)
22257 {
22258 // implicitly convert null value to an empty object
22259 if (is_null())
22260 {
22261 m_type = value_t::object;
22262 m_value.object = create<object_t>();
22263 assert_invariant();
22264 }
22265
22266 if (JSON_HEDLEY_UNLIKELY(!is_object()))
22267 {
22268 JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name())));
22269 }
22270 if (JSON_HEDLEY_UNLIKELY(!j.is_object()))
22271 {
22272 JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name())));
22273 }
22274
22275 for (auto it = j.cbegin(); it != j.cend(); ++it)
22276 {
22277 m_value.object->operator[](it.key()) = it.value();
22278 }
22279 }
22280
22281 /*!
22282 @brief updates a JSON object from another object, overwriting existing keys

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected