JSON for Modern C++ 2.1.0

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
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
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
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[]
parse
parse
parse
parse
parse
parse
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_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< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::from_msgpack | ( | const std::vector< uint8_t > & | v | ) |
| inline static
  Deserializes a given byte vector v to a JSON value using the MessagePack serialization format. Parameters
  [in] | v | a byte vector in MessagePack format
  Returns deserialized JSON value Exceptions
  std::invalid_argument | if unsupported features from MessagePack were used in the given vector v or if the input is not valid MessagePack
  std::out_of_range | if the given vector ends prematurely
  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 3 using json = nlohmann::json; 4 5 int main() 6 { 7 // create byte vector 8 std::vector<uint8_t> v = {0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 9 0x74, 0xc3, 0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d, 10 0x61, 0x00 11 }; 12 13 // deserialize it with MessagePack 14 json j = json::from_msgpack(v); 15 16 // print the deserialized JSON value 17 std::cout << std::setw(2) << j << std::endl; 18 } nlohmann::basic_json::from_msgpack static basic_json from_msgpack(const std::vector< uint8_t > &v) create a JSON value from a byte vector in MessagePack format Definition: json.hpp:8000 nlohmann::json basic_json<> json default JSON class Definition: json.hpp:12610 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>&) for the related CBOR format Definition at line 8000 of file json.hpp.