JSON for Modern C++ 2.1.1

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
begin
begin
boolean_t
cbegin
cend
clear
const_iterator
const_pointer
const_reference
const_reverse_iterator
count
crbegin
crend
detail::external_constructor
diff
difference_type
dump
emplace
emplace_back
empty
end
end
erase
erase
erase
erase
exception
find
find
flatten
from_cbor
from_msgpack
front
front
get
get
get
get
get
get_allocator
get_ptr
get_ptr
get_ref
get_ref
insert
insert
insert
insert
insert
insert
invalid_iterator
is_array
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
iterator
iterator_wrapper
iterator_wrapper
json_serializer
max_size
meta
number_float_t
number_integer_t
number_unsigned_t
object
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[]
operator[]
operator[]
other_error
out_of_range
parse
parse
parse
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
size
size_type
string_t
swap
swap
swap
swap
to_cbor
to_msgpack
type
type_error
type_name
unflatten
value
value
value
value
value_t
value_type
~basic_json
| ## ◆ from_msgpack() 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>
static basic_json nlohmann::basic_json::from_msgpack | ( | const std::vector< uint8_t > & | v,
|  | const size_t | start_index = `0`
| ) |  |
| inline static
Deserializes a given byte vector v 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
negative fixint | number_integer | 0xe0-0xff
  Warning The mapping is incomplete in the sense that not all MessagePack types can be converted to a JSON value. The following MessagePack types are not supported and will yield parse errors: bin 8 - bin 32 (0xc4..0xc6) ext 8 - ext 32 (0xc7..0xc9) fixext 1 - fixext 16 (0xd4..0xd8) Note Any MessagePack output created to_msgpack can be successfully parsed by from_msgpack. Parameters
  [in] | v | a byte vector in MessagePack format
  [in] | start_index | the index to start reading from v (0 by default)
  Returns deserialized JSON value Exceptions
  parse_error.110 | if the given vector ends prematurely
  parse_error.112 | if unsupported features from MessagePack were used in the given vector v 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 byte vector v. Example The example shows the deserialization of a byte vector in MessagePack format to a JSON value. 1 #include "json.hpp" 2 #include <iomanip> // for std::setw 3 4 using json = nlohmann::json; 5 6 int main() 7 { 8 // create byte vector 9 std::vector<uint8_t> v = {0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 10 0x74, 0xc3, 0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d, 11 0x61, 0x00 12 }; 13 14 // deserialize it with MessagePack 15 json j = json::from_msgpack(v); 16 17 // print the deserialized JSON value 18 std::cout << std::setw(2) << j << std::endl; 19 } nlohmann::json basic_json<> json default JSON class Definition: json.hpp:13933 nlohmann::basic_json::from_msgpack static basic_json from_msgpack(const std::vector< uint8_t > &v, const size_t start_index=0) create a JSON value from a byte vector in MessagePack format Definition: json.hpp:9178 Output (play with this example online):
      {
        "compact": true,
        "schema": 0
      }
  The example code above can be translated with
      g++ -std=c++11 -Isrc doc/examples/from_msgpack.cpp -o from_msgpack
See also http://msgpack.org to_msgpack(const basic_json&) for the analogous serialization from_cbor(const std::vector<uint8_t>&, const size_t) for the related CBOR format Since version 2.0.9, parameter start_index since 2.1.1 Definition at line 9178 of file json.hpp.