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
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
| ## ◆ basic_json() [7/9] 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>
JSON_DEPRECATED nlohmann::basic_json::basic_json | ( | std::istream & | i,
|  | const parser_callback_t | cb = `nullptr`
| ) |  |
| inline explicit
  Parameters
  [in,out] | i | stream to read a serialized JSON value from
  [in] | cb | a parser callback function of type parser_callback_t which is used to control the deserialization by filtering unwanted values (optional)
  Complexity Linear in the length of the input. The parser is a predictive LL(1) parser. The complexity can be higher if the parser callback function cb has a super-linear complexity. Note A UTF-8 byte order mark is silently ignored. Deprecated: This constructor is deprecated and will be removed in version 3.0.0 to unify the interface of the library. Deserialization will be done by stream operators or by calling one of the `parse` functions, e.g. parse(std::istream&, const parser_callback_t). That is, calls like `json j(i);` for an input stream i need to be replaced by `json j = json::parse(i);`. See the example below. Example The example below demonstrates constructing a JSON value from a `std::stringstream` with and without callback function. 1 #include <json.hpp> 2 3 using json = nlohmann::json; 4 5 int main() 6 { 7 // a JSON text 8 auto text = R"( 9 { 10 "Image": { 11 "Width": 800, 12 "Height": 600, 13 "Title": "View from 15th Floor", 14 "Thumbnail": { 15 "Url": "http://www.example.com/image/481989943", 16 "Height": 125, 17 "Width": 100 18 }, 19 "Animated" : false, 20 "IDs": [116, 943, 234, 38793] 21 } 22 } 23 )"; 24 25 // fill a stream with JSON text 26 std::stringstream ss; 27 ss << text; 28 29 // create JSON from stream 30 json j_complete(ss); // deprecated! 31 // shall be replaced by: json j_complete = json::parse(ss); 32 std::cout << std::setw(4) << j_complete << "\n\n"; 33 34 35 // define parser callback 36 json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed) 37 { 38 // skip object elements with key "Thumbnail" 39 if (event == json::parse_event_t::key and parsed == json("Thumbnail")) 40 { 41 return false; 42 } 43 else 44 { 45 return true; 46 } 47 }; 48 49 // fill a stream with JSON text 50 ss.clear(); 51 ss << text; 52 53 // create JSON from stream (with callback) 54 json j_filtered(ss, cb); 55 // shall be replaced by: json j_filtered = json::parse(ss, cb); 56 std::cout << std::setw(4) << j_filtered << '\n'; 57 } nlohmann::json basic_json<> json default JSON class Definition: json.hpp:12916 nlohmann::basic_json::parser_callback_t std::function< bool(int depth, parse_event_t event, basic_json &parsed)> parser_callback_t per-element parser callback type Definition: json.hpp:1877 nlohmann::basic_json::parse_event_t::key the parser read a key of a value in an object nlohmann::basic_json::parse_event_t parse_event_t JSON callback events. Definition: json.hpp:1807 Output (play with this example online):
      {
          "Image": {
              "Animated": false,
              "Height": 600,
              "IDs": [
                  116,
                  943,
                  234,
                  38793
              ],
              "Thumbnail": {
                  "Height": 125,
                  "Url": "http://www.example.com/image/481989943",
                  "Width": 100
              },
              "Title": "View from 15th Floor",
              "Width": 800
          }
      }

      {
          "Image": {
              "Animated": false,
              "Height": 600,
              "IDs": [
                  116,
                  943,
                  234,
                  38793
              ],
              "Title": "View from 15th Floor",
              "Width": 800
          }
      }
  The example code above can be translated with
      g++ -std=c++11 -Isrc doc/examples/basic_json__istream.cpp -o basic_json__istream
Since version 2.0.0, deprecated in version 2.0.3, to be removed in version 3.0.0 Definition at line 2396 of file json.hpp.