JSON for Modern C++ 3.7.3

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
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_cbor
from_cbor
from_cbor
from_msgpack
from_msgpack
from_msgpack
from_ubjson
from_ubjson
from_ubjson
front
front
get
get
get
get
get
get
get_allocator
get_binary
get_binary
get_ptr
get_ptr
get_ref
get_ref
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
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
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_msgpack() [3/3] template<typename InputType >
static basic_json nlohmann::basic_json::from_msgpack | ( | InputType && | i,
|  | const bool | strict = `true`,
|  | const bool | allow_exceptions = `true`
| ) |  |
| inlinestatic
Deserializes a given input i to a JSON value using the MessagePack serialization format. The library maps MessagePack types to JSON value types as follows:
MessagePack type | JSON value type | first byte
--- | --- | ---
positive fixint | number_unsigned | 0x00..0x7F
fixmap | object | 0x80..0x8F
fixarray | array | 0x90..0x9F
fixstr | string | 0xA0..0xBF
nil | `null` | 0xC0
false | `false` | 0xC2
true | `true` | 0xC3
float 32 | number_float | 0xCA
float 64 | number_float | 0xCB
uint 8 | number_unsigned | 0xCC
uint 16 | number_unsigned | 0xCD
uint 32 | number_unsigned | 0xCE
uint 64 | number_unsigned | 0xCF
int 8 | number_integer | 0xD0
int 16 | number_integer | 0xD1
int 32 | number_integer | 0xD2
int 64 | number_integer | 0xD3
str 8 | string | 0xD9
str 16 | string | 0xDA
str 32 | string | 0xDB
array 16 | array | 0xDC
array 32 | array | 0xDD
map 16 | object | 0xDE
map 32 | object | 0xDF
bin 8 | binary | 0xC4
bin 16 | binary | 0xC5
bin 32 | binary | 0xC6
ext 8 | binary | 0xC7
ext 16 | binary | 0xC8
ext 32 | binary | 0xC9
fixext 1 | binary | 0xD4
fixext 2 | binary | 0xD5
fixext 4 | binary | 0xD6
fixext 8 | binary | 0xD7
fixext 16 | binary | 0xD8
negative fixint | number_integer | 0xE0-0xFF
  Note Any MessagePack output created to_msgpack can be successfully parsed by from_msgpack. Parameters
  [in] | i | an input in MessagePack 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)
  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 MessagePack were used in the given input i or if the input is not valid MessagePack
  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 MessagePack 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 = {0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 11 0x74, 0xc3, 0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d, 12 0x61, 0x00 13 }; 14 15 // deserialize it with MessagePack 16 json j = json::from_msgpack(v); 17 18 // print the deserialized JSON value 19 std::cout << std::setw(2) << j << std::endl; 20 } 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_msgpack.cpp -o from_msgpack
See also http://msgpack.org to_msgpack(const basic_json&) for the analogous serialization from_cbor(detail::input_adapter&&, const bool, const bool) for the related CBOR format from_ubjson(detail::input_adapter&&, const bool, const bool) for the related UBJSON format from_bson(detail::input_adapter&&, const bool, const bool) for the related BSON 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 Definition at line 23365 of file json.hpp.

nlohmann::basic_json::from_msgpack
static basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
Definition: json.hpp:23365
nlohmann::json
basic_json<> json
default JSON class
Definition: json.hpp:2774