TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ unflatten()

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>>
basic_json nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::unflatten ( ) const
inline

unflatten a previously flattened JSON value

The function restores the arbitrary nesting of a JSON value that has been flattened before using the flatten() function. The JSON value must meet certain constraints:

  1. The value must be an object.
  2. The keys must be JSON pointers (see RFC 6901)
  3. The mapped values must be primitive JSON types.
Returns
the original JSON from a flattened version
Note
Empty objects and arrays are flattened by flatten() to null values and can not unflattened to their original type. Apart from this example, for a JSON value j, the following is always true: j == j.flatten().unflatten().

@complexity Linear in the size the JSON value.

Exceptions
type_error.314if value is not an object
type_error.315if object values are not primitive

@liveexample{The following code shows how a flattened JSON object is unflattened into the original nested JSON object.,unflatten}

See also
see flatten() for the reverse function
Since
version 2.0.0

Definition at line 26095 of file json.hpp.

26096 {
26097 return json_pointer::unflatten(*this);
26098 }
static BasicJsonType unflatten(const BasicJsonType &value)
Definition: json.hpp:13480