JSON for Modern C++ 2.1.1

JSON for Modern C++

These pages contain the API documentation of JSON for Modern C++, a C++11 header-only JSON class.

# Contents

- `basic_json` class
- Functions
  - object inspection
    - dump – value serialization
    - type – type of the value
    - is_primitive , is_structured , is_null , is_boolean , is_number , is_number_integer , is_number_unsigned , is_number_float , is_object , is_array , is_string , is_discarded – check for value type
    - operator value_t – type of the value (implicit conversion)
  - value access
    - get – get a value
    - get_ptr – get a value pointer
    - get_ref – get a value reference
    - operator ValueType – get a value (implicit conversion)
    - value – get a value from an object and return default value if key is not present
  - lexicographical comparison operators
  - serialization
  - deserialization
- Types
  - arrays
  - objects
  - strings
  - booleans
  - numbers
    - signed integers
    - unsigned integers
    - floating-point

# Container function overview

The container functions known from STL have been extended to support the different value types from JSON. However, not all functions can be applied to all value types. Note that the signature of some functions differ between the types; for instance, `at` may be called with either a string to address a key in an object or with an integer to address a value in an array.

group | function | JSON value type
--- | --- | ---
object | array | string | number | boolean | null
iterators | `begin` | `begin` | `begin` | `begin` | `begin` | `begin` | `begin` (returns `end()`)
`cbegin` | `cbegin` | `cbegin` | `cbegin` | `cbegin` | `cbegin` | `cbegin` (returns `cend()`)
`end` | `end` | `end` | `end` | `end` | `end` | `end`
`cend` | `cend` | `cend` | `cend` | `cend` | `cend` | `cend`
`rbegin` | `rbegin` | `rbegin` | `rbegin` | `rbegin` | `rbegin` | `rbegin`
`crbegin` | `crbegin` | `crbegin` | `crbegin` | `crbegin` | `crbegin` | `crbegin`
`rend` | `rend` | `rend` | `rend` | `rend` | `rend` | `rend`
`crend` | `crend` | `crend` | `crend` | `crend` | `crend` | `crend`
element access | `at` | `at` | `at` | throws `std::domain_error` | throws `std::domain_error` | throws `std::domain_error` | throws `std::domain_error`
`operator[]` | `operator[]` | `operator[]` | throws `std::domain_error` | throws `std::domain_error` | throws `std::domain_error` | `operator[]` (creates object) `operator[]` (creates array)
`front` | `front` | `front` | `front` | `front` | `front` | throws `std::out_of_range`
`back` | `back` | `back` | `back` | `back` | `back` | throws `std::out_of_range`
capacity | `empty` | `empty` | `empty` | `empty` (returns `false`) | `empty` (returns `false`) | `empty` (returns `false`) | `empty` (returns `true`)
`size` | `size` | `size` | `size` (returns `1`) | `size` (returns `1`) | `size` (returns `1`) | `size` (returns `0`)
`max_size_` | `max_size` | `max_size` | `max_size` (returns `1`) | `max_size` (returns `1`) | `max_size` (returns `1`) | `max_size` (returns `0`)
modifiers | `clear` | `clear` | `clear` | `clear` | `clear` | `clear` | `clear`
`insert` | throws `std::domain_error` | `insert` | throws `std::domain_error` | throws `std::domain_error` | throws `std::domain_error` | throws `std::domain_error`
`erase` | `erase` | `erase` | `erase` (converts to null) | `erase` (converts to null) | `erase` (converts to null) | throws
`push_back` | `push_back` | `push_back` | throws `std::domain_error` | throws `std::domain_error` | throws `std::domain_error` | `push_back` (creates object) `push_back` (creates array)
`emplace` / `emplace_back` | `emplace` | `emplace_back` | throws `std::domain_error` | throws `std::domain_error` | throws `std::domain_error` | `emplace` (creates object) `emplace_back` (creates array)
`swap` | `swap` | `swap` | `swap` | `swap` | `swap` | `swap`
lookup | `find` | `find` | `find` (returns `end()`) | `find` (returns `end()`) | `find` (returns `end()`) | `find` (returns `end()`) | `find` (returns `end()`)
`count` | `count` | `count` (returns `0`) | `count` (returns `0`) | `count` (returns `0`) | `count` (returns `0`) | `count` (returns `0`)

Copyright
  Copyright © 2013-2017 Niels Lohmann. The code is licensed under the MIT License.

Author
  Niels Lohmann

See also
  https://github.com/nlohmann/json to download the source code

Version
  2.1.1