nlohmann::basic_json - renxiaobo27/json GitHub Wiki

Defined in header json.hpp

template <
    class ObjectType = std::map,
    class ArrayType = std::vector,
    class StringType = std::string,
    class BooleanType = bool,
    class NumberIntegerType = int64_t,
    class NumberFloatType = double,
    class AllocatorType = std::allocator
> class basic_json;

Template parameters

  • ObjectType - container type used for JSON objects
  • ArrayType - container type used for JSON arrays
  • StringType - container type used for JSON strings
  • BooleanType - type used for JSON boolean
  • NumberIntegerType - type used for JSON numbers (integers)
  • NumberFloatType - type used for JSON numbers (floating point)
  • AllocatorType - Allocator type used to allocate internal storage

Typedefs

Type Definition
object_t ObjectType<StringType, basic_json>
array_t ArrayType<basic_json>
string_t StringType
boolean_t BooleanType
number_integer_t NumberIntegerType
number_float_t NumberFloatType
list_init_t std::initializer_list<basic_json>
json basic_json<>

Note the type json is a typedef for the class basic_json with its default types, resulting in the following typedefs:

Type Definition
json::object_t std::map<std::string, json>
json::array_t std::vector<json>
json::string_t std::string
json::boolean_t bool
json::number_integer_t int64_t
json::number_float_t double
json::list_init_t std::initializer_list<json>

Member types

Member type Definition
value_type basic_json
reference value_type&
const_reference const value_type&
difference_type std::ptrdiff_t
size_type std::size_t
allocator_type AllocatorType<basic_json>
pointer std::allocator_traits<allocator_type>::pointer
const_pointer std::allocator_traits<allocator_type>::const_pointer
iterator random access iterator
const_iterator constant random access iterator
reverse_iterator std::reverse_iterator<iterator>
const_reverse_iterator std::reverse_iterator<const_iterator>

Member functions

Type support

Element access

  • operator[]
    access specific element
  • at
    access specific element with bound checking
  • front
    access the first element
  • back
    access the last element

Iterators

Capacity

  • empty
    checks whether the container is empty
  • size
    returns the number of elements
  • max_size
    returns the maximum possible number of elements

Modifiers

  • erase
    erases elements
  • clear
    clears the contents
  • push_back
  • operator+=
  • swap

Lookup

  • find
  • count

Serialization and deserialization

  • dump
  • parse

Non-member functions

  • operator==, operator!=, operator<, operator<=, operator>, operator>=
  • std::swap
  • std::hash

Input/output

  • operator<<, operator>>
  • operator"" _json
⚠️ **GitHub.com Fallback** ⚠️