nlohmann::detail::parser< BasicJsonType, InputAdapterType > Class Template Reference

syntax analysis More...

#include <json.hpp>

Public Member Functions

 parser (InputAdapterType &&adapter, const parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
 a parser reading from an input adapter
 
void parse (const bool strict, BasicJsonType &result)
 public parser interface More...
 
bool accept (const bool strict=true)
 public accept interface More...
 

Private Member Functions

token_type get_token ()
 get next token from lexer
 

Private Attributes

const parser_callback_t< BasicJsonType > callback = nullptr
 callback function
 
token_type last_token = token_type::uninitialized
 the type of the last read token
 
lexer_t m_lexer
 the lexer
 
const bool allow_exceptions = true
 whether to throw exceptions in case of errors
 

Detailed Description

template<typename BasicJsonType, typename InputAdapterType>
class nlohmann::detail::parser< BasicJsonType, InputAdapterType >

syntax analysis

This class implements a recursive descent parser.

Member Function Documentation

◆ parse()

template<typename BasicJsonType , typename InputAdapterType >
void nlohmann::detail::parser< BasicJsonType, InputAdapterType >::parse ( const bool  strict,
BasicJsonType &  result 
)
inline

public parser interface

Parameters
[in]strictwhether to expect the last token to be EOF
[in,out]resultparsed JSON value
Exceptions
parse_error.101in case of an unexpected token
parse_error.102if to_unicode fails or surrogate error
parse_error.103if to_unicode fails

◆ accept()

template<typename BasicJsonType , typename InputAdapterType >
bool nlohmann::detail::parser< BasicJsonType, InputAdapterType >::accept ( const bool  strict = true)
inline

public accept interface

Parameters
[in]strictwhether to expect the last token to be EOF
Returns
whether the input is a proper JSON text
RenderD7 2020-2021 NPI-D7