ToJsonString Class Reference

Produces a JSON-formatted string. More...

#include <json.h>

Inheritance diagram for ToJsonString:
ToJson

Public Member Functions

 ToJsonString (int64_t maxdecimals, const char *nan_string=nullptr, const char *infinity_string=nullptr, const char *minus_infinity_string=nullptr, const char *complex_real_string=nullptr, const char *complex_imag_string=nullptr)
 Creates a ToJsonString with a full set of parameters. More...
 
 ~ToJsonString ()
 Empty destructor; required for some C++ reason. More...
 
void null () override
 Append a null value. More...
 
void boolean (bool x) override
 Append a boolean value x. More...
 
void integer (int64_t x) override
 Append an integer value x. More...
 
void real (double x) override
 Append a real value x. More...
 
void complex (std::complex< double > x) override
 Append a complex value x. More...
 
void string (const char *x, int64_t length) override
 Append a string value x. More...
 
void beginlist () override
 Begin a list. More...
 
void endlist () override
 End the current list. More...
 
void beginrecord () override
 Begin a record. More...
 
void field (const char *x) override
 Insert a key for a key-value pair. More...
 
void endrecord () override
 End the current record. More...
 
void json (const char *data) override
 Write raw JSON as a string. More...
 
const std::string tostring ()
 Return the accumulated data as a string. More...
 
- Public Member Functions inherited from ToJson
virtual ~ToJson ()
 Virtual destructor acts as a first non-inline virtual function that determines a specific translation unit in which vtable shall be emitted. More...
 
void string (const std::string &x)
 Append a string value x. More...
 
void field (const std::string &x)
 Insert a key for a key-value pair. More...
 

Detailed Description

Produces a JSON-formatted string.

Constructor & Destructor Documentation

◆ ToJsonString()

ToJsonString ( int64_t  maxdecimals,
const char *  nan_string = nullptr,
const char *  infinity_string = nullptr,
const char *  minus_infinity_string = nullptr,
const char *  complex_real_string = nullptr,
const char *  complex_imag_string = nullptr 
)

Creates a ToJsonString with a full set of parameters.

Parameters
maxdecimalsMaximum number of decimals for floating-point numbers or -1 for full precision.
nan_stringuser-defined string for a not-a-number (NaN) value representation in JSON format
infinity_stringuser-defined string for a positive infinity representation in JSON format
minus_infinity_stringuser-defined string for a negative infinity representation in JSON format
complex_real_stringuser-defined string for a complex number real part representation in JSON format
complex_imag_stringuser-defined string for a complex number imaginary part representation in JSON format

◆ ~ToJsonString()

Empty destructor; required for some C++ reason.

Member Function Documentation

◆ beginlist()

void beginlist ( )
overridevirtual

Begin a list.

Implements ToJson.

◆ beginrecord()

void beginrecord ( )
overridevirtual

Begin a record.

Implements ToJson.

◆ boolean()

void boolean ( bool  x)
overridevirtual

Append a boolean value x.

Implements ToJson.

◆ complex()

void complex ( std::complex< double >  x)
overridevirtual

Append a complex value x.

Implements ToJson.

◆ endlist()

void endlist ( )
overridevirtual

End the current list.

Implements ToJson.

◆ endrecord()

void endrecord ( )
overridevirtual

End the current record.

Implements ToJson.

◆ field()

void field ( const char *  x)
overridevirtual

Insert a key for a key-value pair.

Implements ToJson.

◆ integer()

void integer ( int64_t  x)
overridevirtual

Append an integer value x.

Implements ToJson.

◆ json()

void json ( const char *  data)
overridevirtual

Write raw JSON as a string.

Implements ToJson.

◆ null()

void null ( )
overridevirtual

Append a null value.

Implements ToJson.

◆ real()

void real ( double  x)
overridevirtual

Append a real value x.

Implements ToJson.

◆ string()

void string ( const char *  x,
int64_t  length 
)
overridevirtual

Append a string value x.

Implements ToJson.

◆ tostring()

const std::string tostring ( )

Return the accumulated data as a string.


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