Low-level JSON parser. The caller must provide a handler class to receive callbacks.
Inherits from orcus::json::parser_base
Public Types
Public Functions
orcus::json_parser::
json_parser
(const char *p, size_t n, handler_type &hdl)¶Constructor.
p
: pointer to a string stream containing JSON string. n
: size of the stream. hdl
: handler class instance. orcus::json_parser::
parse
()¶Call this method to start parsing.
Public Functions
json_parser_handler::
begin_parse
()¶Called when the parsing begins.
json_parser_handler::
end_parse
()¶Called when the parsing ends.
json_parser_handler::
begin_array
()¶Called when the opening brace of an array is encountered.
json_parser_handler::
end_array
()¶Called when the closing brace of an array is encountered.
json_parser_handler::
begin_object
()¶Called when the opening curly brace of an object is encountered.
json_parser_handler::
object_key
(const char *p, size_t len, bool transient)¶Called when a key value string of an object is encountered.
p
: pointer to the first character of the key value string. len
: length of the 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. json_parser_handler::
end_object
()¶Called when the closing curly brace of an object is encountered.
json_parser_handler::
boolean_true
()¶Called when a boolean ‘true’ keyword is encountered.
json_parser_handler::
boolean_false
()¶Called when a boolean ‘false’ keyword is encountered.
json_parser_handler::
null
()¶Called when a ‘null’ keyword is encountered.
json_parser_handler::
string
(const char *p, size_t len, bool transient)¶Called when a string value is encountered.
p
: pointer to the first character of the string value. len
: length of the 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. json_parser_handler::
number
(double val)¶Called when a numeric value is encountered.
val
: numeric value.