MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / update

Function update

native/thirdpart/json/json.hpp:19952–19975  ·  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

19950 @since version 3.0.0
19951 */
19952 void update(const_reference j)
19953 {
19954 // implicitly convert null value to an empty object
19955 if (is_null())
19956 {
19957 m_type = value_t::object;
19958 m_value.object = create<object_t>();
19959 assert_invariant();
19960 }
19961
19962 if (JSON_HEDLEY_UNLIKELY(not is_object()))
19963 {
19964 JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name())));
19965 }
19966 if (JSON_HEDLEY_UNLIKELY(not j.is_object()))
19967 {
19968 JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name())));
19969 }
19970
19971 for (auto it = j.cbegin(); it != j.cend(); ++it)
19972 {
19973 m_value.object->operator[](it.key()) = it.value();
19974 }
19975 }
19976
19977 /*!
19978 @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
cbeginMethod · 0.45
cendMethod · 0.45
operator[]Method · 0.45
keyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected