TSDuck v3.40-4033
MPEG Transport Stream Toolkit
|
Namespace for JSON (JavaScript Object Notation) classes. More...
Classes | |
class | Array |
Implementation of a JSON array. More... | |
class | False |
Implementation of a JSON false literal. More... | |
class | Null |
Implementation of a JSON null literal. More... | |
class | Number |
Implementation of a JSON number. More... | |
class | Object |
Implementation of a JSON object. More... | |
class | OutputArgs |
Command line arguments for JSON reports (--json , --json-line , --json-udp , --json-tcp ). More... | |
class | RunningDocument |
Representation of a "running" JSON document which is displayed on the fly. More... | |
class | String |
Implementation of a JSON string. More... | |
class | True |
Implementation of a JSON true literal. More... | |
class | Value |
Abstract base class of a JSON value. More... | |
Typedefs | |
using | ValuePtr = std::shared_ptr< Value > |
Safe pointer to a JSON value (not thread-safe). | |
using | ValuePtrList = std::list< ValuePtr > |
A list of safe pointers to JSON values. | |
using | ValuePtrVector = std::vector< ValuePtr > |
A vector of safe pointers to JSON values. | |
Enumerations | |
enum class | Type { Null , True , False , String , Number , Object , Array } |
Definition of the type of a value. More... | |
Functions | |
ValuePtr | Bool (bool value) |
Create a boolean JSON value. | |
ValuePtr | Factory (Type type, const UString &value=UString()) |
Create a JSON value by type. | |
bool | IsInlineJSON (const UString &name) |
Check if a "file name" is in fact inline JSON content instead of a file name. | |
bool | LoadFile (ValuePtr &value, const UString &filename, Report &report=(ts::NullReport::Instance())) |
Load a JSON value (typically an object or array) from a text file. | |
bool | LoadStream (ValuePtr &value, std::istream &strm, Report &report=(ts::NullReport::Instance())) |
Load a JSON value (typically an object or array) from an open text stream. | |
bool | Parse (ValuePtr &value, const UString &text, Report &report=(ts::NullReport::Instance())) |
Parse a JSON value (typically an object or array). | |
bool | Parse (ValuePtr &value, const UStringList &lines, Report &report=(ts::NullReport::Instance())) |
Parse a JSON value (typically an object or array). | |
bool | Parse (ValuePtr &value, TextParser &parser, bool jsonOnly, Report &report=(ts::NullReport::Instance())) |
Parse a JSON value (typically an object or array). | |
Variables | |
Null | NullValue |
A general-purpose null JSON value. | |
const TypeEnumWrapper | TypeEnum |
Enumeration description of ts::json::Type. | |
Namespace for JSON (JavaScript Object Notation) classes.
|
strong |
Create a JSON value by type.
[in] | type | The type JSON object to create. |
[in] | value | Optional value. For TypeString, use this value. For TypeNumber, convert the string into a number (zero on error). For all other types, the value is ignored. |
ValuePtr ts::json::Bool | ( | bool | value | ) |
bool ts::json::Parse | ( | ValuePtr & | value, |
const UStringList & | lines, | ||
Report & | report = (ts::NullReport::Instance()) |
||
) |
Parse a JSON value (typically an object or array).
[out] | value | A smart pointer to the parsed JSON value (null on error). |
[in] | lines | List of text lines forming the JSON value. |
[in,out] | report | Where to report errors. |
bool ts::json::Parse | ( | ValuePtr & | value, |
const UString & | text, | ||
Report & | report = (ts::NullReport::Instance()) |
||
) |
Parse a JSON value (typically an object or array).
[out] | value | A smart pointer to the parsed JSON value (null on error). |
[in] | text | The text forming the JSON value. |
[in,out] | report | Where to report errors. |
bool ts::json::Parse | ( | ValuePtr & | value, |
TextParser & | parser, | ||
bool | jsonOnly, | ||
Report & | report = (ts::NullReport::Instance()) |
||
) |
Parse a JSON value (typically an object or array).
[out] | value | A smart pointer to the parsed JSON value (null on error). |
[in,out] | parser | A text parser. |
[in] | jsonOnly | If true, the parsed text shall not contain anything else than the JSON value (except white spaces). If false, on output, the position of the parser is right after the JSON value. |
[in,out] | report | Where to report errors. |
bool ts::json::LoadFile | ( | ValuePtr & | value, |
const UString & | filename, | ||
Report & | report = (ts::NullReport::Instance()) |
||
) |
Load a JSON value (typically an object or array) from a text file.
[out] | value | A smart pointer to the parsed JSON value (null on error). |
[in] | filename | The name of the JSON file. If empty or "-", the standard input is used. If filename starts with "{" or "[", this is considered as "inline JSON content". The document is loaded from this string instead of reading a file. |
[in,out] | report | Where to report errors. |
bool ts::json::LoadStream | ( | ValuePtr & | value, |
std::istream & | strm, | ||
Report & | report = (ts::NullReport::Instance()) |
||
) |
Load a JSON value (typically an object or array) from an open text stream.
[out] | value | A smart pointer to the parsed JSON value (null on error). |
[in,out] | strm | A standard text stream in input mode. |
[in,out] | report | Where to report errors. |
bool ts::json::IsInlineJSON | ( | const UString & | name | ) |
Check if a "file name" is in fact inline JSON content instead of a file name.
We currently only test if the name starts with '{' or '['. This will fail if we port TSDuck to OpenVMS, however...
[in] | name | A file name string. |