TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ update() [2/2]

template<template< typename U, typename V, typename... Args > class ObjectType = std::map, template< typename U, typename... Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator, template< typename T, typename SFINAE=void > class JSONSerializer = adl_serializer, class BinaryType = std::vector<std::uint8_t>>
void nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::update ( const_reference  j)
inline

updates a JSON object from another object, overwriting existing keys

Inserts all values from JSON object j and overwrites existing keys.

Parameters
[in]jJSON object to read values from
Exceptions
type_error.312if 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 elements to insert.

@liveexample{The example shows how update() is used.,update}

See also
https://docs.python.org/3.6/library/stdtypes.html#dict.update
Since
version 3.0.0

Definition at line 23693 of file json.hpp.

23694 {
23695 // implicitly convert null value to an empty object
23696 if (is_null())
23697 {
23698 m_type = value_t::object;
23699 m_value.object = create<object_t>();
23701 }
23702
23703 if (JSON_HEDLEY_UNLIKELY(!is_object()))
23704 {
23705 JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()), *this));
23706 }
23707
23708 if (JSON_HEDLEY_UNLIKELY(!j.is_object()))
23709 {
23710 JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name()), *this));
23711 }
23712
23713 for (auto it = j.cbegin(); it != j.cend(); ++it)
23714 {
23715 m_value.object->operator[](it.key()) = it.value();
23716#if JSON_DIAGNOSTICS
23717 m_value.object->operator[](it.key()).m_parent = this;
23718#endif
23719 }
23720 }
void assert_invariant(bool check_parents=true) const noexcept
checks the class invariants
Definition: json.hpp:18935
constexpr bool is_object() const noexcept
return whether value is an object
Definition: json.hpp:20410
json_value m_value
the value of the current element
Definition: json.hpp:24928
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
Definition: json.hpp:24883
constexpr bool is_null() const noexcept
return whether value is null
Definition: json.hpp:20251
@ object
object (unordered set of name/value pairs)