serialization to CBOR and MessagePack values More...
#include <json.h>
serialization to CBOR and MessagePack values
Public Member Functions | |
binary_writer (output_adapter_t< CharType > adapter) | |
create a binary writer More... | |
void | write_bson (const BasicJsonType &j) |
void | write_cbor (const BasicJsonType &j) |
void | write_msgpack (const BasicJsonType &j) |
void | write_ubjson (const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true) |
Static Public Member Functions | |
template<typename C = CharType, enable_if_t< std::is_signed< C >::value &&std::is_signed< char >::value > * = nullptr> | |
static constexpr CharType | to_char_type (std::uint8_t x) noexcept |
template<typename C = CharType, enable_if_t< std::is_signed< C >::value &&std::is_unsigned< char >::value > * = nullptr> | |
static CharType | to_char_type (std::uint8_t x) noexcept |
template<typename C = CharType, enable_if_t< std::is_unsigned< C >::value > * = nullptr> | |
static constexpr CharType | to_char_type (std::uint8_t x) noexcept |
template<typename InputCharType , typename C = CharType, enable_if_t< std::is_signed< C >::value &&std::is_signed< char >::value &&std::is_same< char, typename std::remove_cv< InputCharType >::type >::value > * = nullptr> | |
static constexpr CharType | to_char_type (InputCharType x) noexcept |
|
private |
|
private |
|
private |
|
inlineexplicit |
create a binary writer
[in] | adapter | output adapter to write to |
Definition at line 12764 of file json.h.
References nlohmann::detail::JSON_ASSERT(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::oa.
|
inlinestaticprivate |
Definition at line 13776 of file json.h.
References nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_element_size(), nlohmann::to_string(), and nlohmann::detail::value.
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_element_size(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_array().
|
inlinestaticprivate |
Definition at line 13791 of file json.h.
References nlohmann::detail::value.
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_element_size().
|
inlinestaticprivate |
Calculates the size necessary to serialize the JSON value j with its name.
Definition at line 13833 of file json.h.
References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_array_size(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_binary_size(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_entry_header_size(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_integer_size(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_object_size(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_string_size(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_unsigned_size(), nlohmann::detail::JSON_ASSERT(), nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, and nlohmann::detail::string.
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_array_size().
|
inlinestaticprivate |
Definition at line 13629 of file json.h.
References nlohmann::detail::out_of_range::create(), and nlohmann::to_string().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_element_size().
|
inlinestaticprivate |
Definition at line 13706 of file json.h.
References nlohmann::detail::value.
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_element_size().
|
inlinestaticprivate |
Calculates the size of the BSON serialization of the given JSON-object j.
[in] | j | JSON value to serialize |
Definition at line 13927 of file json.h.
References nlohmann::detail::value.
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_element_size(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_object().
|
inlinestaticprivate |
Definition at line 13676 of file json.h.
References nlohmann::detail::value.
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_element_size().
|
inlinestaticconstexprprivatenoexcept |
Definition at line 13734 of file json.h.
References nlohmann::detail::value.
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_element_size().
|
inlinestaticconstexprprivate |
Definition at line 13963 of file json.h.
References nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type().
|
inlinestaticconstexprprivate |
Definition at line 13958 of file json.h.
References nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_compact_float().
|
inlinestaticconstexprprivate |
Definition at line 13977 of file json.h.
References nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type().
|
inlinestaticconstexprprivate |
Definition at line 13972 of file json.h.
References nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_compact_float().
|
inlinestaticconstexprprivate |
|
inlinestaticconstexprprivate |
Definition at line 14209 of file json.h.
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::ubjson_prefix(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number_with_ubjson_prefix().
|
inlinestaticconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
Definition at line 14278 of file json.h.
Referenced by nlohmann::detail::serializer< BasicJsonType >::dump_escaped(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_cbor_float_prefix(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_msgpack_float_prefix(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_array(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_boolean(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_entry_header(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_object(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_cbor(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_msgpack(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number_with_ubjson_prefix(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_ubjson().
|
inlinestaticnoexcept |
Definition at line 14285 of file json.h.
References nlohmann::detail::value.
|
inlinestaticconstexprnoexcept |
|
inlineprivatenoexcept |
determine the type prefix of container values
Definition at line 14129 of file json.h.
References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_ubjson_float_prefix(), nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, and nlohmann::detail::string.
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_ubjson().
|
inline |
[in] | j | JSON value to serialize |
Definition at line 12773 of file json.h.
References nlohmann::detail::type_error::create(), nlohmann::detail::object, and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_object().
|
inlineprivate |
Writes a BSON element with key name and array value.
Definition at line 13799 of file json.h.
References nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_array_size(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::oa, nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type(), nlohmann::to_string(), nlohmann::detail::value, nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_element(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_entry_header().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_element().
|
inlineprivate |
Writes a BSON element with key name and binary value value.
Definition at line 13818 of file json.h.
References nlohmann::detail::binary_writer< BasicJsonType, CharType >::oa, nlohmann::detail::value, nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_entry_header(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_element().
|
inlineprivate |
Writes a BSON element with key name and boolean value value.
Definition at line 13656 of file json.h.
References nlohmann::detail::binary_writer< BasicJsonType, CharType >::oa, nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type(), nlohmann::detail::value, and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_entry_header().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_element().
|
inlineprivate |
Writes a BSON element with key name and double value value.
Definition at line 13666 of file json.h.
References nlohmann::detail::value, and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_entry_header().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_element().
|
inlineprivate |
Serializes the JSON value j to BSON and associates it with the key name.
name | The name to associate with the JSON entity j within the current BSON document |
Definition at line 13881 of file json.h.
References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::JSON_ASSERT(), nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, nlohmann::detail::string, nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_array(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_binary(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_boolean(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_double(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_integer(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_null(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_object_entry(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_string(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_unsigned().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_array(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_object().
|
inlineprivate |
Writes the given element_type and name to the output adapter.
Definition at line 13644 of file json.h.
References nlohmann::detail::binary_writer< BasicJsonType, CharType >::oa, and nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_array(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_binary(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_boolean(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_double(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_integer(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_null(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_object_entry(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_string(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_unsigned().
|
inlineprivate |
Writes a BSON element with key name and integer value.
Definition at line 13716 of file json.h.
References nlohmann::detail::value, and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_entry_header().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_element().
|
inlineprivate |
Writes a BSON element with key name and null value.
Definition at line 13698 of file json.h.
References nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_entry_header().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_element().
|
inlineprivate |
[in] | j | JSON value to serialize |
Definition at line 13942 of file json.h.
References nlohmann::detail::binary_writer< BasicJsonType, CharType >::calc_bson_object_size(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::oa, nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type(), nlohmann::detail::value, and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_element().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_object_entry().
|
inlineprivate |
Writes a BSON element with key name and object value.
Definition at line 13766 of file json.h.
References nlohmann::detail::value, nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_entry_header(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_object().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_element().
|
inlineprivate |
Writes a BSON element with key name and string value value.
Definition at line 13684 of file json.h.
References nlohmann::detail::binary_writer< BasicJsonType, CharType >::oa, nlohmann::detail::value, and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_entry_header().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_element().
|
inlineprivate |
Writes a BSON element with key name and unsigned value.
Definition at line 13744 of file json.h.
References nlohmann::detail::out_of_range::create(), nlohmann::to_string(), nlohmann::detail::value, and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_entry_header().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_element().
|
inline |
[in] | j | JSON value to serialize |
Definition at line 12793 of file json.h.
References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::cbor, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::binary_writer< BasicJsonType, CharType >::oa, nlohmann::detail::object, nlohmann::detail::string, nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_compact_float(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number().
|
inlineprivate |
Definition at line 14251 of file json.h.
References nlohmann::detail::cbor, nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_cbor_float_prefix(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_msgpack_float_prefix(), nlohmann::detail::dtoa_impl::n, nlohmann::detail::binary_writer< BasicJsonType, CharType >::oa, and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_cbor(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_msgpack().
|
inline |
[in] | j | JSON value to serialize |
Definition at line 13098 of file json.h.
References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::msgpack, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::binary_writer< BasicJsonType, CharType >::oa, nlohmann::detail::object, nlohmann::detail::string, nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_compact_float(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number().
|
inlineprivate |
Definition at line 14235 of file json.h.
References nlohmann::detail::binary_writer< BasicJsonType, CharType >::is_little_endian, nlohmann::detail::dtoa_impl::n, and nlohmann::detail::binary_writer< BasicJsonType, CharType >::oa.
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_binary(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_cbor(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_compact_float(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_msgpack(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number_with_ubjson_prefix().
|
inlineprivate |
Definition at line 13989 of file json.h.
References nlohmann::detail::binary_writer< BasicJsonType, CharType >::get_ubjson_float_prefix(), nlohmann::detail::dtoa_impl::n, nlohmann::detail::binary_writer< BasicJsonType, CharType >::oa, and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number().
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number_with_ubjson_prefix(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_ubjson().
|
inlineprivate |
Definition at line 14002 of file json.h.
References nlohmann::detail::dtoa_impl::n, nlohmann::detail::binary_writer< BasicJsonType, CharType >::oa, nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number_with_ubjson_prefix().
|
inlineprivate |
Definition at line 14065 of file json.h.
References nlohmann::detail::dtoa_impl::n, nlohmann::detail::binary_writer< BasicJsonType, CharType >::oa, nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number_with_ubjson_prefix().
|
inline |
[in] | j | JSON value to serialize |
[in] | use_count | whether to use '#' prefixes (optimized format) |
[in] | use_type | whether to use '$' prefixes (optimized format) |
[in] | add_prefix | whether prefixes need to be used for this value |
Definition at line 13422 of file json.h.
References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::JSON_ASSERT(), nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::binary_writer< BasicJsonType, CharType >::oa, nlohmann::detail::object, nlohmann::detail::string, nlohmann::detail::binary_writer< BasicJsonType, CharType >::to_char_type(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::ubjson_prefix(), nlohmann::detail::dtoa_impl::v, and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number_with_ubjson_prefix().
|
private |
whether we can assume little endianess
Definition at line 14314 of file json.h.
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number().
|
private |
the output
Definition at line 14317 of file json.h.
Referenced by nlohmann::detail::binary_writer< BasicJsonType, CharType >::binary_writer(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_array(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_binary(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_boolean(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_entry_header(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_object(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_bson_string(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_cbor(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_compact_float(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_msgpack(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number(), nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_number_with_ubjson_prefix(), and nlohmann::detail::binary_writer< BasicJsonType, CharType >::write_ubjson().