TSDuck v3.38-3699
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::json::RunningDocument Class Reference

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ RunningDocument()

ts::json::RunningDocument::RunningDocument ( Report report = (ts::NullReport::Instance()))
inlineexplicit

Constructor.

Parameters
[in,out]reportWhere to report errors.

Member Function Documentation

◆ open()

bool ts::json::RunningDocument::open ( const ValuePtr root,
const fs::path &  fileName = fs::path(),
std::ostream &  strm = std::cout 
)

Initialize the running document.

Parameters
[in]rootRoot JSON value.
  • If root is a null pointer, assume an empty array.
  • If root is an array, its current elements are printed and the array is left open.
  • If root is an object, it is recursively searched until the first array is found. Everything else is printed and this array is left open. If no array is found, this is an error.
  • If root is any other type of JSON value, this is an error.
[in]fileNameOutput file name to create. When empty or "-", strm is used for output.
[in,out]strmThe default output text stream when fileName is empty or "-". The referenced stream object must remain valid as long as this object.
Returns
True on success, false on error.

◆ add()

void ts::json::RunningDocument::add ( const Value value)

Add one JSON value in the open array of the running document.

Parameters
[in]valueThe JSON value to add.

◆ close()

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.


The documentation for this class was generated from the following file: