JSON for Modern C++ 3.9.1

__pad3__
accept
accept
accept
allocator_type
array
array_t
at
at
at
at
at
at
back
back
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
basic_json
begin
begin
binary
binary
binary
binary
binary_t
boolean_t
cbegin
cbor_tag_handler_t
cend
clear
const_iterator
const_pointer
const_reference
const_reverse_iterator
contains
contains
count
crbegin
crend
detail::external_constructor
diff
difference_type
dump
emplace
emplace_back
empty
end
end
erase
erase
erase
erase
error_handler_t
exception
find
find
flatten
from_bson
from_bson
from_bson
from_bson
from_cbor
from_cbor
from_cbor
from_cbor
from_msgpack
from_msgpack
from_msgpack
from_msgpack
from_ubjson
from_ubjson
from_ubjson
from_ubjson
front
front
get
get
get_allocator
get_binary
get_binary
get_ptr
get_ptr
get_ref
get_ref
get_to
get_to
get_to
initializer_list_t
input_format_t
insert
insert
insert
insert
insert
insert
insert_iterator
invalid_iterator
is_array
is_binary
is_boolean
is_discarded
is_null
is_number
is_number_float
is_number_integer
is_number_unsigned
is_object
is_primitive
is_string
is_structured
items
items
iterator
iterator_wrapper
iterator_wrapper
json_pointer
json_sax_t
json_serializer
m_value
max_size
merge_patch
meta
number_float_t
number_integer_t
number_unsigned_t
object
object_comparator_t
object_t
operator value_t
operator ValueType
operator!=
operator!=
operator!=
operator+=
operator+=
operator+=
operator+=
operator<
operator<
operator<
operator<<
operator<<
operator<=
operator<=
operator<=
operator=
operator==
operator==
operator==
operator>
operator>
operator>
operator>=
operator>=
operator>=
operator>>
operator>>
operator[]
operator[]
operator[]
operator[]
operator[]
operator[]
operator[]
operator[]
other_error
out_of_range
parse
parse
parse
parse_error
parse_event_t
parser_callback_t
patch
pointer
push_back
push_back
push_back
push_back
rbegin
rbegin
reference
rend
rend
reverse_iterator
sax_parse
sax_parse
sax_parse
size
size_type
string_t
swap
swap
swap
swap
swap
swap
swap
to_bson
to_bson
to_bson
to_cbor
to_cbor
to_cbor
to_msgpack
to_msgpack
to_msgpack
to_ubjson
to_ubjson
to_ubjson
type
type_error
type_name
unflatten
update
update
value
value
value
value
value_t
value_type
~basic_json
| ## ◆ from_cbor() [3/4] 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>> template<typename InputType >
static basic_json nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::from_cbor | ( | InputType && | i,
|  | const bool | strict = `true`,
|  | const bool | allow_exceptions = `true`,
|  | const cbor_tag_handler_t | tag_handler = `cbor_tag_handler_t::error`
| ) |  |
| inline static
Deserializes a given input i to a JSON value using the CBOR (Concise Binary Object Representation) serialization format. The library maps CBOR types to JSON value types as follows:
CBOR type | JSON value type | first byte
--- | --- | ---
Integer | number_unsigned | 0x00..0x17
Unsigned integer | number_unsigned | 0x18
Unsigned integer | number_unsigned | 0x19
Unsigned integer | number_unsigned | 0x1A
Unsigned integer | number_unsigned | 0x1B
Negative integer | number_integer | 0x20..0x37
Negative integer | number_integer | 0x38
Negative integer | number_integer | 0x39
Negative integer | number_integer | 0x3A
Negative integer | number_integer | 0x3B
Byte string | binary | 0x40..0x57
Byte string | binary | 0x58
Byte string | binary | 0x59
Byte string | binary | 0x5A
Byte string | binary | 0x5B
UTF-8 string | string | 0x60..0x77
UTF-8 string | string | 0x78
UTF-8 string | string | 0x79
UTF-8 string | string | 0x7A
UTF-8 string | string | 0x7B
UTF-8 string | string | 0x7F
array | array | 0x80..0x97
array | array | 0x98
array | array | 0x99
array | array | 0x9A
array | array | 0x9B
array | array | 0x9F
map | object | 0xA0..0xB7
map | object | 0xB8
map | object | 0xB9
map | object | 0xBA
map | object | 0xBB
map | object | 0xBF
False | `false` | 0xF4
True | `true` | 0xF5
Null | `null` | 0xF6
Half-Precision Float | number_float | 0xF9
Single-Precision Float | number_float | 0xFA
Double-Precision Float | number_float | 0xFB
  Warning The mapping is incomplete in the sense that not all CBOR types can be converted to a JSON value. The following CBOR types are not supported and will yield parse errors (parse_error.112): date/time (0xC0..0xC1) bignum (0xC2..0xC3) decimal fraction (0xC4) bigfloat (0xC5) expected conversions (0xD5..0xD7) simple values (0xE0..0xF3, 0xF8) undefined (0xF7) CBOR allows map keys of any type, whereas JSON only allows strings as keys in object values. Therefore, CBOR maps with keys other than UTF-8 strings are rejected (parse_error.113). Note Any CBOR output created to_cbor can be successfully parsed by from_cbor. Parameters
  [in] | i | an input in CBOR format convertible to an input adapter
  [in] | strict | whether to expect the input to be consumed until EOF (true by default)
  [in] | allow_exceptions | whether to throw exceptions in case of a parse error (optional, true by default)
  [in] | tag_handler | how to treat CBOR tags (optional, error by default)
  Returns deserialized JSON value; in case of a parse error and allow_exceptions set to `false`, the return value will be value_t::discarded. Exceptions
  parse_error.110 | if the given input ends prematurely or the end of file was not reached when strict was set to true
  parse_error.112 | if unsupported features from CBOR were used in the given input v or if the input is not valid CBOR
  parse_error.113 | if a string was expected as map key, but not found
  Complexity Linear in the size of the input i. Example The example shows the deserialization of a byte vector in CBOR format to a JSON value. 1 #include <iostream> 2 #include <iomanip> 3 #include <nlohmann/json.hpp> 4 5 using json = nlohmann::json; 6 7 int main() 8 { 9 // create byte vector 10 std::vector<uint8_t> v = {0xa2, 0x67, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 11 0x74, 0xf5, 0x66, 0x73, 0x63, 0x68, 0x65, 0x6d, 12 0x61, 0x00 13 }; 14 15 // deserialize it with CBOR 16 json j = json::from_cbor(v); 17 18 // print the deserialized JSON value 19 std::cout << std::setw(2) << j << std::endl; 20 } nlohmann::basic_json::from_cbor static basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error) create a JSON value from an input in CBOR format Definition: json.hpp:24642 nlohmann::json basic_json<> json default JSON class Definition: json.hpp:3385 Output (play with this example online):
      {
        "compact": true,
        "schema": 0
      }
  The example code above can be translated with
      g++ -std=c++11 -Isingle_include doc/examples/from_cbor.cpp -o from_cbor
See also http://cbor.io see to_cbor(const basic_json&) for the analogous serialization see from_msgpack(InputType&&, const bool, const bool) for the related MessagePack format see from_ubjson(InputType&&, const bool, const bool) for the related UBJSON format Since version 2.0.9; parameter start_index since 2.1.1; changed to consume input adapters, removed start_index parameter, and added strict parameter since 3.0.0; added allow_exceptions parameter since 3.2.0; added tag_handler parameter since 3.9.0. Definition at line 24642 of file json.hpp.