...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
A serializer for JSON.
Defined in header <boost/json/serializer.hpp>
class serializer;
Name |
Description |
---|---|
Returns |
|
Read the next buffer of serialized JSON. |
|
Reset the serializer for a new element. |
|
serializer [constructor] |
Move constructor (deleted) |
~serializer [destructor] |
Destructor. |
This class traverses an instance of a library type and emits serialized JSON
text by filling in one or more caller-provided buffers. To use, declare a
variable and call reset
with a pointer to the variable
you want to serialize. Then call read
over and over until done
returns true
.
This demonstrates how the serializer may be used to print a JSON value to an output stream.
void print( std::ostream& os, value const& jv) { serializer sr; sr.reset( &jv ); while( ! sr.done() ) { char buf[ 4000 ]; os << sr.read( buf ); } }
The same instance may not be accessed concurrently.
Convenience header <boost/json.hpp>