TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ parse() [2/3]

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 InputType >
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::parse ( InputType &&  i,
const parser_callback_t  cb = nullptr,
const bool  allow_exceptions = true,
const bool  ignore_comments = false 
)
inlinestatic

deserialize from a compatible input

Template Parameters
InputTypeA compatible input, for instance
  • an std::istream object
  • a FILE pointer
  • a C-style array of characters
  • a pointer to a null-terminated string of single byte characters
  • an object obj for which begin(obj) and end(obj) produces a valid pair of iterators.
Parameters
[in]iinput to read from
[in]cba parser callback function of type parser_callback_t which is used to control the deserialization by filtering unwanted values (optional)
[in]allow_exceptionswhether to throw exceptions in case of a parse error (optional, true by default)
[in]ignore_commentswhether 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.101if a parse error occurs; example: ""unexpected end of input; expected string literal""
parse_error.102if to_unicode fails or surrogate error
parse_error.103if 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 or reading from the input i has a super-linear complexity.

Note
A UTF-8 byte order mark is silently ignored.

@liveexample{The example below demonstrates the parse() function reading from an array.,parse__array__parser_callback_t}

@liveexample{The example below demonstrates the parse() function with and without callback function.,parse__string__parser_callback_t}

@liveexample{The example below demonstrates the parse() function with and without callback function.,parse__istream__parser_callback_t}

@liveexample{The example below demonstrates the parse() function reading from a contiguous container.,parse__contiguouscontainer__parser_callback_t}

Since
version 2.0.3 (contiguous containers); version 3.9.0 allowed to ignore comments.

Definition at line 24605 of file json.hpp.

24609 {
24610 basic_json result;
24611 parser(detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(true, result);
24612 return result;
24613 }
basic_json(const value_t v)
create an empty value with a given type
Definition: json.hpp:19164