serializer
A serializer for JSON.
Synopsis
Defined in header <boost/json/serializer.hpp>.
class serializer
: private detail::writer;
Member Functions
Name | Description |
---|---|
Returns |
|
Read the next buffer of serialized JSON. |
|
Reset the serializer for a new element. |
|
|
Move constructor (deleted) |
|
Destructor. |
Description
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
.
Example
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 );
}
}
Thread Safety
The same instance may not be accessed concurrently.
Convenience header <boost/json.hpp>.