TSDuck v3.40-4033
MPEG Transport Stream Toolkit
|
Representation of a "running" JSON document which is displayed on the fly. More...
#include <tsjsonRunningDocument.h>
Public Member Functions | |
RunningDocument (Report &report=(ts::NullReport::Instance())) | |
Constructor. | |
~RunningDocument () | |
Destructor. | |
void | add (const Value &value) |
Add one JSON value in the open array of the running document. | |
void | close () |
Close the running document. | |
bool | open (const ValuePtr &root, const fs::path &fileName=fs::path(), std::ostream &strm=std::cout) |
Initialize the running document. | |
Representation of a "running" JSON document which is displayed on the fly.
The idea is to display or save a JSON document containing an array of values which is built value by value without waiting for the end of the document.
The JSON document is initially displayed with whatever can be displayed and the final array is left open so that new values can be added later.
The "open" array can be the root value of the JSON document or inside one or more levels of objects.
|
inlineexplicit |
Constructor.
[in,out] | report | Where to report errors. |
bool ts::json::RunningDocument::open | ( | const ValuePtr & | root, |
const fs::path & | fileName = fs::path() , |
||
std::ostream & | strm = std::cout |
||
) |
Initialize the running document.
[in] | root | Root JSON value.
|
[in] | fileName | Output file name to create. When empty or "-", strm is used for output. |
[in,out] | strm | The default output text stream when fileName is empty or "-". The referenced stream object must remain valid as long as this object. |
void ts::json::RunningDocument::add | ( | const Value & | value | ) |
Add one JSON value in the open array of the running document.
[in] | value | The JSON value to add. |
void ts::json::RunningDocument::close | ( | ) |
Close the running document.
If the JSON structure is still open, it is closed. The output file, if any, is closed.