Project
Loading...
Searching...
No Matches
nlohmann::detail::parser< BasicJsonType > Class Template Reference

syntax analysis More...

#include <json.h>

Public Types

enum class  parse_event_t : uint8_t {
  object_start , object_end , array_start , array_end ,
  key , value
}
 
using parser_callback_t = std::function< bool(int depth, parse_event_t event, BasicJsonType &parsed)>
 

Public Member Functions

 parser (detail::input_adapter_t adapter, const parser_callback_t cb=nullptr, const bool allow_exceptions_=true)
 a parser reading from an input adapter
 
void parse (const bool strict, BasicJsonType &result)
 public parser interface
 
bool accept (const bool strict=true)
 public accept interface
 

Detailed Description

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

syntax analysis

This class implements a recursive decent parser.

Definition at line 3016 of file json.h.

Member Typedef Documentation

◆ parser_callback_t

template<typename BasicJsonType >
using nlohmann::detail::parser< BasicJsonType >::parser_callback_t = std::function<bool(int depth, parse_event_t event, BasicJsonType& parsed)>

Definition at line 3041 of file json.h.

Member Enumeration Documentation

◆ parse_event_t

template<typename BasicJsonType >
enum class nlohmann::detail::parser::parse_event_t : uint8_t
strong
Enumerator
object_start 

the parser read { and started to process a JSON object

object_end 

the parser read } and finished processing a JSON object

array_start 

the parser read [ and started to process a JSON array

array_end 

the parser read ] and finished processing a JSON array

key 

the parser read a key of a value in an object

value 

the parser finished reading a JSON value

Definition at line 3026 of file json.h.

Constructor & Destructor Documentation

◆ parser()

template<typename BasicJsonType >
nlohmann::detail::parser< BasicJsonType >::parser ( detail::input_adapter_t  adapter,
const parser_callback_t  cb = nullptr,
const bool  allow_exceptions_ = true 
)
inlineexplicit

a parser reading from an input adapter

Definition at line 3045 of file json.h.

Member Function Documentation

◆ accept()

template<typename BasicJsonType >
bool nlohmann::detail::parser< BasicJsonType >::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

Definition at line 3095 of file json.h.

◆ parse()

template<typename BasicJsonType >
void nlohmann::detail::parser< BasicJsonType >::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

Definition at line 3062 of file json.h.


The documentation for this class was generated from the following file: