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