TSDuck v3.43-4441
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::json::YAML Class Reference

Conversion between JSON and YAML (experimental). More...

#include <tsjsonYAML.h>

Public Types

enum class  StringType {
  KEY ,
  SCALAR ,
  MULTI_LINE ,
  QUOTED
}
 String type, according to YAML usage. More...
 

Static Public Member Functions

static StringType GetStringType (const UString &str)
 Determine the type of a string.
 
static void PrintAsYAML (TextFormatter &out, const json::Value &value, bool with_headers=false)
 Format a JSON value as YAML text.
 
static void PrintLiteralBlock (TextFormatter &out, const UString &str)
 Format a string as a literal block scalar.
 
static UString QuotedString (const UString &str)
 Build a quoted string for YAML.
 

Detailed Description

Conversion between JSON and YAML (experimental).

Member Enumeration Documentation

◆ StringType

enum class ts::json::YAML::StringType
strong

String type, according to YAML usage.

There is a strict ordering: each level is a superset of the preceding one.

Enumerator
KEY 

Can be used as mapping key.

SCALAR 

Can be used without quotes.

MULTI_LINE 

Can be used in a multi-line string (after '|') without quotes.

QUOTED 

Requires quotes.

Member Function Documentation

◆ PrintAsYAML()

static void ts::json::YAML::PrintAsYAML ( TextFormatter out,
const json::Value value,
bool  with_headers = false 
)
static

Format a JSON value as YAML text.

Parameters
[in,out]outThe text formatter which is used to output.
[in]valueThe JSON value to format.
[in]with_headersWhen true, add the standard YAML header ("---") and trailer ("...").

◆ GetStringType()

static StringType ts::json::YAML::GetStringType ( const UString str)
static

Determine the type of a string.

Parameters
[in]strThe string to check.
Returns
The type of the string.
See also
https://www.yaml.info/learn/quote.html

Warning: if the returned type is MULTI_LINE, be sure to check if the string ends with a new line (use "|") or without (use "|-").

◆ QuotedString()

static UString ts::json::YAML::QuotedString ( const UString str)
static

Build a quoted string for YAML.

Parameters
[in]strThe string to quote.
Returns
The quoted string.

◆ PrintLiteralBlock()

static void ts::json::YAML::PrintLiteralBlock ( TextFormatter out,
const UString str 
)
static

Format a string as a literal block scalar.

Do not print the last end of line.

Parameters
[in,out]outThe text formatter which is used to output.
[in]strThe string to format.

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