Provides methods for streaming JSON objects.
More...
#include <json_stream.h>
+ Inheritance diagram for json_stream_objectt:
+ Collaboration diagram for json_stream_objectt:
Provide key-value lookup capabilities for the JSON object.
Lookup the key of a non-streaming JSON element.
Push back a JSON element into the current object stream.
Add a JSON object stream for a specific key.
Add a JSON array stream for a specific key.
Outputs the current current child stream and closes this JSON stream.
Protected Member Functions
Output non-streaming JSON properties and flushes and closes the child stream.
Output the finalizing character for a JSON object.
Constructor to be used by derived classes.
Create a new JSON array child stream.
Create a new JSON object child stream.
Outputs the delimiter between JSON elements.
Additional Inherited Members
Non-streaming JSON elements These will be printed when closing the stream or creating a child stream.
Denotes whether the current stream is open or has been invalidated.
Is the current element the first element in the object or array? This is required to know whether a delimiter must be output or not.
The current child stream.
Detailed Description
Provides methods for streaming JSON objects.
Definition at line 139 of file json_stream.h.
Constructor & Destructor Documentation
◆ json_stream_objectt()
json_stream_objectt::json_stream_objectt
(
std::ostream &
out,
)
explicit
Constructor for json_stream_objectt.
- Parameters
-
out The stream that is to be used to output the JSON object.
indent Current indentation level.
Definition at line 59 of file json_stream.cpp.
◆ ~json_stream_objectt()
json_stream_objectt::~json_stream_objectt
(
)
inlineoverride
Member Function Documentation
◆ operator[]() [1/2]
jsont & json_stream_objectt::operator[]
(
const std::string &
key )
inline
Provide key-value lookup capabilities for the JSON object.
Provided for compatibility with jsont.
- Parameters
-
key The key to be looked up inside the attributes of the JSON object.
Definition at line 148 of file json_stream.h.
◆ operator[]() [2/2]
const jsont & json_stream_objectt::operator[]
(
const std::string &
key )
const
inline
Lookup the key of a non-streaming JSON element.
- Parameters
-
key The key to be looked up inside the attributes of the JSON object.
- Returns
- The value that corresponds to the key if found, a null_json_object otherwise.
Definition at line 163 of file json_stream.h.
◆ output_child_stream()
void json_stream_objectt::output_child_stream
(
)
overrideprotectedvirtual
Output non-streaming JSON properties and flushes and closes the child stream.
Implements json_streamt.
Definition at line 133 of file json_stream.cpp.
◆ output_finalizer()
void json_stream_objectt::output_finalizer
(
)
overrideprotectedvirtual
◆ push_back()
void json_stream_objectt::push_back
(
const std::string &
key,
)
inline
Push back a JSON element into the current object stream.
Note the pushed key won't be available via operator[], as it has been output already. Provided for compatibility with jsont.
- Parameters
-
key new key to create in the streamed object
json a non-streaming JSON element
Definition at line 178 of file json_stream.h.
◆ push_back_stream_array()
Add a JSON array stream for a specific key.
- Parameters
-
key key of the JSON property
Definition at line 120 of file json_stream.cpp.
◆ push_back_stream_object()
Add a JSON object stream for a specific key.
- Parameters
-
key key of the JSON property
Definition at line 106 of file json_stream.cpp.
The documentation for this class was generated from the following files: