JSON parser
-
template<typename HandlerT>
class json_parser : public orcus::json::parser_base Parser for JSON documents.
- Template Parameters:
HandlerT – Hanlder type with member functions for event callbacks. Refer to json_handler.
Public Functions
-
json_parser(std::string_view content, handler_type &hdl)
Constructor.
- Parameters:
content – string stream containing JSON string.
hdl – handler class instance.
-
void parse()
Call this method to start parsing.
Parser handler
-
class json_handler
Public Functions
-
inline void begin_parse()
Called when the parsing begins.
-
inline void end_parse()
Called when the parsing ends.
-
inline void begin_array()
Called when the opening brace of an array is encountered.
-
inline void end_array()
Called when the closing brace of an array is encountered.
-
inline void begin_object()
Called when the opening curly brace of an object is encountered.
-
inline void object_key(std::string_view key, bool transient)
Called when a key value string of an object is encountered.
- Parameters:
key – key value string.
transient – true if the string value is stored in a temporary buffer which is not guaranteed to hold the string value after the end of this callback. When false, the pointer points to somewhere in the JSON stream being parsed.
-
inline void end_object()
Called when the closing curly brace of an object is encountered.
-
inline void boolean_true()
Called when a boolean ‘true’ keyword is encountered.
-
inline void boolean_false()
Called when a boolean ‘false’ keyword is encountered.
-
inline void null()
Called when a ‘null’ keyword is encountered.
-
inline void string(std::string_view val, bool transient)
Called when a string value is encountered.
- Parameters:
val – string value.
transient – true if the string value is stored in a temporary buffer which is not guaranteed to hold the string value after the end of this callback. When false, the pointer points to somewhere in the JSON stream being parsed.
-
inline void number(double val)
Called when a numeric value is encountered.
- Parameters:
val – numeric value.
-
inline void begin_parse()