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
| ## ◆ parse() [3/3] template<class IteratorType , typename std::enable_if< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< IteratorType >::iterator_category >::value, int >::type = 0>
static basic_json nlohmann::basic_json::parse | ( | IteratorType | first,
|  | IteratorType | last,
|  | const parser_callback_t | cb = `nullptr`,
|  | const bool | allow_exceptions = `true`
| ) |  |
| inline static
  This function reads from an iterator range of a container with contiguous storage of 1-byte values. Compatible container types include `std::vector`, `std::string`, `std::array`, `std::valarray`, and `std::initializer_list`. Furthermore, C-style arrays can be used with `std::begin()`/`std::end()`. User-defined containers can be used as long as they implement random-access iterators and a contiguous storage. Precondition The iterator range is contiguous. Violating this precondition yields undefined behavior. This precondition is enforced with an assertion. Each element in the range has a size of 1 byte. Violating this precondition yields undefined behavior. This precondition is enforced with a static assertion. Warning There is no way to enforce all preconditions at compile-time. If the function is called with noncompliant iterators and with assertions switched off, the behavior is undefined and will most likely yield segmentation violation. Template Parameters
  IteratorType | iterator of container with contiguous storage
  Parameters
  [in] | first | begin of the range to parse (included)
  [in] | last | end of the range to parse (excluded)
  [in] | cb | a parser callback function of type parser_callback_t which is used to control the deserialization by filtering unwanted values (optional)
  [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.101 | in case of an unexpected token
  parse_error.102 | if to_unicode fails or surrogate error
  parse_error.103 | if to_unicode fails
  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. Example The example below demonstrates the `parse()` function reading from an iterator range. 1 #include <iostream> 2 #include <iomanip> 3 #include <nlohmann/json.hpp> 4 5 using json = nlohmann::json; 6 7 int main() 8 { 9 // a JSON text given as std::vector 10 std::vector<uint8_t> text = {'[', '1', ',', '2', ',', '3', ']', '\0'}; 11 12 // parse and serialize JSON 13 json j_complete = json::parse(text.begin(), text.end()); 14 std::cout << std::setw(4) << j_complete << "\n\n"; 15 } Output (play with this example online):
      [
          1,
          2,
          3
      ]
  The example code above can be translated with
      g++ -std=c++11 -Isingle_include doc/examples/parse__iteratortype__parser_callback_t.cpp -o parse__iteratortype__parser_callback_t
Since version 2.0.3 Definition at line 22577 of file json.hpp.

nlohmann::basic_json::parse
static basic_json parse(InputType &&i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true)
deserialize from a compatible input
Definition: json.hpp:22415
nlohmann::json
basic_json<> json
default JSON class
Definition: json.hpp:2774