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 >::flatten |
( |
| ) |
const |
|
inline |
return flattened JSON value
The function creates a JSON object whose keys are JSON pointers (see RFC 6901) and whose values are all primitive. The original JSON value can be restored using the unflatten() function.
- Returns
- an object that maps JSON pointers to primitive values
- Note
- Empty objects and arrays are flattened to
null
and will not be reconstructed correctly by the unflatten() function.
@complexity Linear in the size the JSON value.
@liveexample{The following code shows how a JSON object is flattened to an object whose keys consist of JSON pointers.,flatten}
- See also
- see unflatten() for the reverse function
- Since
- version 2.0.0
Definition at line 26058 of file json.hpp.
26059 {
26062 return result;
26063 }
basic_json(const value_t v)
create an empty value with a given type
static void flatten(const std::string &reference_string, const BasicJsonType &value, BasicJsonType &result)
@ object
object (unordered set of name/value pairs)