![]() |
An incremental SAX parser for serialized JSON.
Defined in header <boost/json/detail/basic_parser.hpp>
class basic_parser
Name |
Description |
---|---|
Returns the current depth of the JSON being parsed. |
|
Return true if a complete JSON has been parsed. |
|
Returns the maximum allowed depth of input JSON. Set the maximum allowed depth of input JSON. |
|
Destructor. |
Name |
Description |
---|---|
Reset the state, to parse a new document. |
|
Parse JSON incrementally. |
This implements a SAX-style parser. The serialized JSON is presented to the
parser by calling to write_some
, write, and finish. The
parsing events are realized through member function calls to a handler passed
as an argument to the write functions.
The parser may dynamically allocate intermediate storage as needed to accommodate the nesting level of the JSON being parsed. This storage is freed when the parser is destroyed, allowing the parser to cheaply re-use this memory when parsing subsequent JSONs, improving performance.
Users who wish to parse JSON into the DOM container value
will not use this class directly;
instead they will create an instance of parser
and use that instead. Alternatively,
they may call the function parse
. This class is designed for
users who wish to perform custom actions instead of building a value
. For example, to produce a
DOM from an external library.
To use this class it is necessary to create a derived class which calls
reset
at the beginning of parsing a new JSON, and then calls write_some
one or more times with
the serialized JSON.
The parser is strict: no extensions are supported. Only compliant JSON is recognized.
Convenience header <boost/json.hpp>