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, class BinaryType = std::vector<std::uint8_t>>
template<typename IteratorType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::parse |
( |
IteratorType |
first, |
|
|
IteratorType |
last, |
|
|
const parser_callback_t |
cb = nullptr , |
|
|
const bool |
allow_exceptions = true , |
|
|
const bool |
ignore_comments = false |
|
) |
| |
|
inlinestatic |
deserialize from a pair of character iterators
The value_type of the iterator must be a integral type with size of 1, 2 or 4 bytes, which will be interpreted respectively as UTF-8, UTF-16 and UTF-32.
- Parameters
-
[in] | first | iterator to start of character range |
[in] | last | iterator to end of character range |
[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) |
[in] | ignore_comments | whether comments should be ignored and treated like whitespace (true) or yield a parse error (true); (optional, false 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 | if a parse error occurs; example: ""unexpected end of input; expected string literal"" |
parse_error.102 | if to_unicode fails or surrogate error |
parse_error.103 | if to_unicode fails |
Definition at line 24643 of file json.hpp.
24648 {
24650 parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(true, result);
24651 return result;
24652 }
basic_json(const value_t v)
create an empty value with a given type