Electroneum
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions | Variables
json.hpp File Reference
#include <algorithm>
#include <array>
#include <cassert>
#include <ciso646>
#include <clocale>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <locale>
#include <map>
#include <memory>
#include <numeric>
#include <sstream>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
Include dependency graph for json.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  nlohmann::detail::exception
 general exception of the basic_json class More...
 
class  nlohmann::detail::parse_error
 exception indicating a parse error More...
 
class  nlohmann::detail::invalid_iterator
 exception indicating errors with iterators More...
 
class  nlohmann::detail::type_error
 exception indicating executing a member function with a wrong type More...
 
class  nlohmann::detail::out_of_range
 exception indicating access out of the defined range More...
 
class  nlohmann::detail::other_error
 exception indicating other errors More...
 
struct  nlohmann::detail::conjunction<... >
 
struct  nlohmann::detail::conjunction< B1 >
 
struct  nlohmann::detail::conjunction< B1, Bn... >
 
struct  nlohmann::detail::negation< B >
 
struct  nlohmann::detail::priority_tag< N >
 
struct  nlohmann::detail::priority_tag< 0 >
 
struct  nlohmann::detail::external_constructor< value_t >
 
struct  nlohmann::detail::external_constructor< value_t::boolean >
 
struct  nlohmann::detail::external_constructor< value_t::string >
 
struct  nlohmann::detail::external_constructor< value_t::number_float >
 
struct  nlohmann::detail::external_constructor< value_t::number_unsigned >
 
struct  nlohmann::detail::external_constructor< value_t::number_integer >
 
struct  nlohmann::detail::external_constructor< value_t::array >
 
struct  nlohmann::detail::external_constructor< value_t::object >
 
struct  nlohmann::detail::is_compatible_object_type_impl< B, RealType, CompatibleObjectType >
 
struct  nlohmann::detail::is_compatible_object_type_impl< true, RealType, CompatibleObjectType >
 
struct  nlohmann::detail::is_compatible_object_type< BasicJsonType, CompatibleObjectType >
 
struct  nlohmann::detail::is_basic_json_nested_type< BasicJsonType, T >
 
struct  nlohmann::detail::is_compatible_array_type< BasicJsonType, CompatibleArrayType >
 
struct  nlohmann::detail::is_compatible_integer_type_impl< bool, typename, typename >
 
struct  nlohmann::detail::is_compatible_integer_type_impl< true, RealIntegerType, CompatibleNumberIntegerType >
 
struct  nlohmann::detail::is_compatible_integer_type< RealIntegerType, CompatibleNumberIntegerType >
 
struct  nlohmann::detail::has_from_json< BasicJsonType, T >
 
struct  nlohmann::detail::has_non_default_from_json< BasicJsonType, T >
 
struct  nlohmann::detail::has_to_json< BasicJsonType, T >
 
struct  nlohmann::detail::to_json_fn
 
struct  nlohmann::detail::from_json_fn
 
struct  nlohmann::detail::static_const< T >
 
struct  nlohmann::adl_serializer< typename, typename >
 default JSONSerializer template argument More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >
 a class to store JSON values More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::iter_impl< U >
 a template for a random access iterator for the basic_json class More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::json_reverse_iterator< Base >
 a template for a reverse iterator class More...
 
union  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::json_value
 a JSON value More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::iteration_proxy< IteratorType >
 proxy class for the iterator_wrapper functions More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::output_adapter< CharType >
 abstract output adapter interface More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::output_vector_adapter< CharType >
 output adapter for byte vectors More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::output_stream_adapter< CharType >
 putput adatpter for output streams More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::output_string_adapter< CharType >
 output adapter for basic_string More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::serializer
 wrapper around the serialization functions More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::primitive_iterator_t
 an iterator for primitive JSON types More...
 
struct  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::internal_iterator
 an iterator value More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::iteration_proxy< IteratorType >
 proxy class for the iterator_wrapper functions More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::iteration_proxy< IteratorType >::iteration_proxy_internal
 helper class for iteration More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::iter_impl< U >
 a template for a random access iterator for the basic_json class More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::json_reverse_iterator< Base >
 a template for a reverse iterator class More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::input_adapter
 abstract input adapter interface More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::cached_input_stream_adapter
 input adapter for cached stream input More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::input_buffer_adapter
 input adapter for buffer input More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::binary_reader
 deserialization of CBOR and MessagePack values More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::binary_writer
 serialization to CBOR and MessagePack values More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::lexer
 lexical analysis More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::parser
 syntax analysis More...
 
class  nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::json_pointer
 JSON Pointer. More...
 
struct  std::hash< nlohmann::json >
 hash value for JSON objects More...
 
struct  std::less<::nlohmann::detail::value_t >
 specialization for std::less<value_t> More...
 

Namespaces

 nlohmann
 namespace for Niels Lohmann
 
 nlohmann::detail
 unnamed namespace with internal helper functions
 
 nlohmann::anonymous_namespace{json.hpp}
 namespace to hold default to_json / from_json functions
 
 std
 

Macros

#define JSON_DEPRECATED
 
#define JSON_THROW(exception)   std::abort()
 
#define JSON_TRY   if(true)
 
#define JSON_CATCH(exception)   if(false)
 
#define JSON_LIKELY(x)   x
 
#define JSON_UNLIKELY(x)   x
 
#define NLOHMANN_JSON_HAS_HELPER(type)
 Helper to determine whether there's a key_type for T. More...
 

Typedefs

template<bool B, typename T = void>
using nlohmann::detail::enable_if_t = typename std::enable_if< B, T >::type
 
template<typename T >
using nlohmann::detail::uncvref_t = typename std::remove_cv< typename std::remove_reference< T >::type >::type
 
using nlohmann::json = basic_json<>
 default JSON class More...
 

Enumerations

enum  nlohmann::detail::value_t : uint8_t {
  nlohmann::detail::value_t::null, nlohmann::detail::value_t::object, nlohmann::detail::value_t::array, nlohmann::detail::value_t::string,
  nlohmann::detail::value_t::boolean, nlohmann::detail::value_t::number_integer, nlohmann::detail::value_t::number_unsigned, nlohmann::detail::value_t::number_float,
  nlohmann::detail::value_t::discarded
}
 the JSON type enumeration More...
 

Functions

bool nlohmann::detail::operator< (const value_t lhs, const value_t rhs) noexcept
 comparison operator for JSON types More...
 
 nlohmann::detail::NLOHMANN_JSON_HAS_HELPER (mapped_type)
 
 nlohmann::detail::NLOHMANN_JSON_HAS_HELPER (key_type)
 
 nlohmann::detail::NLOHMANN_JSON_HAS_HELPER (value_type)
 
 nlohmann::detail::NLOHMANN_JSON_HAS_HELPER (iterator)
 
template<typename BasicJsonType , typename T , enable_if_t< std::is_same< T, typename BasicJsonType::boolean_t >::value, int > = 0>
void nlohmann::detail::to_json (BasicJsonType &j, T b) noexcept
 
template<typename BasicJsonType , typename CompatibleString , enable_if_t< std::is_constructible< typename BasicJsonType::string_t, CompatibleString >::value, int > = 0>
void nlohmann::detail::to_json (BasicJsonType &j, const CompatibleString &s)
 
template<typename BasicJsonType , typename FloatType , enable_if_t< std::is_floating_point< FloatType >::value, int > = 0>
void nlohmann::detail::to_json (BasicJsonType &j, FloatType val) noexcept
 
template<typename BasicJsonType , typename CompatibleNumberUnsignedType , enable_if_t< is_compatible_integer_type< typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType >::value, int > = 0>
void nlohmann::detail::to_json (BasicJsonType &j, CompatibleNumberUnsignedType val) noexcept
 
template<typename BasicJsonType , typename CompatibleNumberIntegerType , enable_if_t< is_compatible_integer_type< typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType >::value, int > = 0>
void nlohmann::detail::to_json (BasicJsonType &j, CompatibleNumberIntegerType val) noexcept
 
template<typename BasicJsonType , typename EnumType , enable_if_t< std::is_enum< EnumType >::value, int > = 0>
void nlohmann::detail::to_json (BasicJsonType &j, EnumType e) noexcept
 
template<typename BasicJsonType >
void nlohmann::detail::to_json (BasicJsonType &j, const std::vector< bool > &e)
 
template<typename BasicJsonType , typename CompatibleArrayType , enable_if_t< is_compatible_array_type< BasicJsonType, CompatibleArrayType >::value or std::is_same< typename BasicJsonType::array_t, CompatibleArrayType >::value, int > = 0>
void nlohmann::detail::to_json (BasicJsonType &j, const CompatibleArrayType &arr)
 
template<typename BasicJsonType , typename CompatibleObjectType , enable_if_t< is_compatible_object_type< BasicJsonType, CompatibleObjectType >::value, int > = 0>
void nlohmann::detail::to_json (BasicJsonType &j, const CompatibleObjectType &arr)
 
template<typename BasicJsonType , typename T , std::size_t N, enable_if_t< not std::is_constructible< typename BasicJsonType::string_t, T(&)[N]>::value, int > = 0>
void nlohmann::detail::to_json (BasicJsonType &j, T(&arr)[N])
 
template<typename BasicJsonType , typename ArithmeticType , enable_if_t< std::is_arithmetic< ArithmeticType >::value and not std::is_same< ArithmeticType, typename BasicJsonType::boolean_t >::value, int > = 0>
void nlohmann::detail::get_arithmetic_value (const BasicJsonType &j, ArithmeticType &val)
 
template<typename BasicJsonType >
void nlohmann::detail::from_json (const BasicJsonType &j, typename BasicJsonType::boolean_t &b)
 
template<typename BasicJsonType >
void nlohmann::detail::from_json (const BasicJsonType &j, typename BasicJsonType::string_t &s)
 
template<typename BasicJsonType >
void nlohmann::detail::from_json (const BasicJsonType &j, typename BasicJsonType::number_float_t &val)
 
template<typename BasicJsonType >
void nlohmann::detail::from_json (const BasicJsonType &j, typename BasicJsonType::number_unsigned_t &val)
 
template<typename BasicJsonType >
void nlohmann::detail::from_json (const BasicJsonType &j, typename BasicJsonType::number_integer_t &val)
 
template<typename BasicJsonType , typename EnumType , enable_if_t< std::is_enum< EnumType >::value, int > = 0>
void nlohmann::detail::from_json (const BasicJsonType &j, EnumType &e)
 
template<typename BasicJsonType >
void nlohmann::detail::from_json (const BasicJsonType &j, typename BasicJsonType::array_t &arr)
 
template<typename BasicJsonType , typename T , typename Allocator , enable_if_t< std::is_convertible< BasicJsonType, T >::value, int > = 0>
void nlohmann::detail::from_json (const BasicJsonType &j, std::forward_list< T, Allocator > &l)
 
template<typename BasicJsonType , typename CompatibleArrayType >
void nlohmann::detail::from_json_array_impl (const BasicJsonType &j, CompatibleArrayType &arr, priority_tag< 0 >)
 
template<typename BasicJsonType , typename CompatibleArrayType >
auto nlohmann::detail::from_json_array_impl (const BasicJsonType &j, CompatibleArrayType &arr, priority_tag< 1 >) -> decltype(arr.reserve(std::declval< typename CompatibleArrayType::size_type >()), void())
 
template<typename BasicJsonType , typename CompatibleArrayType , enable_if_t< is_compatible_array_type< BasicJsonType, CompatibleArrayType >::value and std::is_convertible< BasicJsonType, typename CompatibleArrayType::value_type >::value and not std::is_same< typename BasicJsonType::array_t, CompatibleArrayType >::value, int > = 0>
void nlohmann::detail::from_json (const BasicJsonType &j, CompatibleArrayType &arr)
 
template<typename BasicJsonType , typename CompatibleObjectType , enable_if_t< is_compatible_object_type< BasicJsonType, CompatibleObjectType >::value, int > = 0>
void nlohmann::detail::from_json (const BasicJsonType &j, CompatibleObjectType &obj)
 
template<typename BasicJsonType , typename ArithmeticType , enable_if_t< std::is_arithmetic< ArithmeticType >::value and not std::is_same< ArithmeticType, typename BasicJsonType::number_unsigned_t >::value and not std::is_same< ArithmeticType, typename BasicJsonType::number_integer_t >::value and not std::is_same< ArithmeticType, typename BasicJsonType::number_float_t >::value and not std::is_same< ArithmeticType, typename BasicJsonType::boolean_t >::value, int > = 0>
void nlohmann::detail::from_json (const BasicJsonType &j, ArithmeticType &val)
 
template<>
void std::swap (nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value and is_nothrow_move_assignable< nlohmann::json >::value)
 exchanges the values of two JSON objects More...
 
nlohmann::json operator"" _json (const char *s, std::size_t n)
 user-defined string literal for JSON values More...
 
nlohmann::json::json_pointer operator"" _json_pointer (const char *s, std::size_t n)
 user-defined string literal for JSON pointer More...
 

Variables

constexpr const auto & nlohmann::anonymous_namespace{json.hpp}::to_json = detail::static_const<detail::to_json_fn>::value
 
constexpr const auto & nlohmann::anonymous_namespace{json.hpp}::from_json = detail::static_const<detail::from_json_fn>::value
 

Macro Definition Documentation

◆ JSON_CATCH

#define JSON_CATCH (   exception)    if(false)

◆ JSON_DEPRECATED

#define JSON_DEPRECATED

◆ JSON_LIKELY

#define JSON_LIKELY (   x)    x

◆ JSON_THROW

#define JSON_THROW (   exception)    std::abort()

◆ JSON_TRY

#define JSON_TRY   if(true)

◆ JSON_UNLIKELY

#define JSON_UNLIKELY (   x)    x

◆ NLOHMANN_JSON_HAS_HELPER

#define NLOHMANN_JSON_HAS_HELPER (   type)
Value:
template<typename T> struct has_##type { \
private: \
template<typename U, typename = typename U::type> \
static int detect(U &&); \
static void detect(...); \
public: \
static constexpr bool value = \
std::is_integral<decltype(detect(std::declval<T>()))>::value; \
}
type
Definition: json.h:74

Helper to determine whether there's a key_type for T.

This helper is used to tell associative containers apart from other containers such as sequence containers. For instance, std::map passes the test as it contains a mapped_type, whereas std::vector fails the test.

See also
http://stackoverflow.com/a/7728728/266378
Since
version 1.0.0, overworked in version 2.0.6

Function Documentation

◆ operator"" _json()

nlohmann::json operator"" _json ( const char *  s,
std::size_t  n 
)
inline

user-defined string literal for JSON values

This operator implements a user-defined string literal for JSON objects. It can be used by adding "_json" to a string literal and returns a JSON object if no parse error occurred.

Parameters
[in]sa string representation of a JSON object
[in]nthe length of string s
Returns
a JSON object
Since
version 1.0.0

◆ operator"" _json_pointer()

nlohmann::json::json_pointer operator"" _json_pointer ( const char *  s,
std::size_t  n 
)
inline

user-defined string literal for JSON pointer

This operator implements a user-defined string literal for JSON Pointers. It can be used by adding "_json_pointer" to a string literal and returns a JSON pointer object if no parse error occurred.

Parameters
[in]sa string representation of a JSON Pointer
[in]nthe length of string s
Returns
a JSON pointer object
Since
version 2.0.0