BDE 4.14.0 Production release
Loading...
Searching...
No Matches
baljsn::DatumUtil Struct Reference

#include <baljsn_datumutil.h>

Static Public Member Functions

static int decode (bdld::ManagedDatum *result, const bsl::string_view &json)
 
static int decode (bdld::ManagedDatum *result, const bsl::string_view &json, const DatumDecoderOptions &options)
 
static int decode (bdld::ManagedDatum *result, bsl::ostream *errorStream, const bsl::string_view &json)
 
static int decode (bdld::ManagedDatum *result, bsl::ostream *errorStream, const bsl::string_view &json, const DatumDecoderOptions &options)
 
static int decode (bdld::ManagedDatum *result, bsl::streambuf *jsonBuffer)
 
static int decode (bdld::ManagedDatum *result, bsl::streambuf *jsonBuffer, const DatumDecoderOptions &options)
 
static int decode (bdld::ManagedDatum *result, bsl::ostream *errorStream, bsl::streambuf *jsonBuffer)
 
static int decode (bdld::ManagedDatum *result, bsl::ostream *errorStream, bsl::streambuf *jsonBuffer, const DatumDecoderOptions &options)
 
static int encode (bsl::string *result, const bdld::Datum &datum)
 
static int encode (std::string *result, const bdld::Datum &datum)
 
static int encode (bsl::string *result, const bdld::Datum &datum, const DatumEncoderOptions &options)
 
static int encode (std::string *result, const bdld::Datum &datum, const DatumEncoderOptions &options)
 
static int encode (bsl::ostream &stream, const bdld::Datum &datum)
 
static int encode (bsl::ostream &stream, const bdld::Datum &datum, const DatumEncoderOptions &options)
 

Detailed Description

This struct provides a namespace for a suite of functions that convert between a JSON formated string and a bdld::Datum.

Member Function Documentation

◆ decode() [1/8]

int baljsn::DatumUtil::decode ( bdld::ManagedDatum result,
bsl::ostream *  errorStream,
bsl::streambuf *  jsonBuffer 
)
inlinestatic

◆ decode() [2/8]

static int baljsn::DatumUtil::decode ( bdld::ManagedDatum result,
bsl::ostream *  errorStream,
bsl::streambuf *  jsonBuffer,
const DatumDecoderOptions options 
)
static

Decode the JSON string provided by the specified jsonBuffer into the specified result. If the optionally specified errorStream is non-null, a description of any errors that occur during parsing will be output to this stream. If the optionally specified options argument is not present, treat it as a default-constructed DatumDecoderOptions. Return 0 on success, and a negative value if json could not be decoded (either because it is ill-formed, or if a constraint imposed by option is violated). An error status will be returned if json contains arrays or objects that are nested beyond a depth configured by options.maxNestedDepth(). The mapping of types in JSON to the types supported by Datum is described in Supported Types .

◆ decode() [3/8]

int baljsn::DatumUtil::decode ( bdld::ManagedDatum result,
bsl::ostream *  errorStream,
const bsl::string_view json 
)
inlinestatic

◆ decode() [4/8]

int baljsn::DatumUtil::decode ( bdld::ManagedDatum result,
bsl::ostream *  errorStream,
const bsl::string_view json,
const DatumDecoderOptions options 
)
inlinestatic

Decode the specified json into the specified result. If the optionally specified errorStream is non-null, a description of any errors that occur during parsing will be output to this stream. If the optionally specified options argument is not present, treat it as a default-constructed DatumDecoderOptions. Return 0 on success, and a negative value if json could not be decoded (either because it is ill-formed, or if a constraint imposed by option is violated). An error status will be returned if json contains arrays or objects that are nested beyond a depth configured by options.maxNestedDepth(). The mapping of types in JSON to the types supported by Datum is described in Supported Types .

◆ decode() [5/8]

int baljsn::DatumUtil::decode ( bdld::ManagedDatum result,
bsl::streambuf *  jsonBuffer 
)
inlinestatic

◆ decode() [6/8]

int baljsn::DatumUtil::decode ( bdld::ManagedDatum result,
bsl::streambuf *  jsonBuffer,
const DatumDecoderOptions options 
)
inlinestatic

◆ decode() [7/8]

int baljsn::DatumUtil::decode ( bdld::ManagedDatum result,
const bsl::string_view json 
)
inlinestatic

◆ decode() [8/8]

int baljsn::DatumUtil::decode ( bdld::ManagedDatum result,
const bsl::string_view json,
const DatumDecoderOptions options 
)
inlinestatic

◆ encode() [1/6]

int baljsn::DatumUtil::encode ( bsl::ostream &  stream,
const bdld::Datum datum 
)
inlinestatic

◆ encode() [2/6]

static int baljsn::DatumUtil::encode ( bsl::ostream &  stream,
const bdld::Datum datum,
const DatumEncoderOptions options 
)
static

Encode the specified datum as a JSON string, and write it into the specified stream. Return 0 on success, and a negative value if datum could not be encoded (which may leave a partial JSON sequence on the stream). If the optionally specified options argument is not present, treat it as a default-constructed DatumEncoderOptions. If options.strictTypes is true and a type that is not supported by JSON, or a singular double value (e.g., NaN or infinity) is being encoded (see Supported Types return a positive value, but also populate result with an encoded JSON string (i.e., the value of result is the same regardless of the strictTypes option, but if strictTypes is true a non-zero positive status will be returned). The mapping of types supported by Datum to JSON types is described in Supported Types .

◆ encode() [3/6]

int baljsn::DatumUtil::encode ( bsl::string result,
const bdld::Datum datum 
)
inlinestatic

◆ encode() [4/6]

static int baljsn::DatumUtil::encode ( bsl::string result,
const bdld::Datum datum,
const DatumEncoderOptions options 
)
static

◆ encode() [5/6]

int baljsn::DatumUtil::encode ( std::string *  result,
const bdld::Datum datum 
)
inlinestatic

Encode the specified datum as a JSON string, and load the specified result with the encoded JSON string. Return 0 on success, and a negative value if datum could not be encoded (with no effect on result). If the optionally specified options argument is not present, treat it as a default-constructed DatumEncoderOptions. If options.strictTypes is true and a type that is not supported by JSON, or a singular double value (e.g., NaN or infinity) is being encoded (see Supported Types return a positive value, but also populate result with an encoded JSON string (i.e., the value of result is the same regardless of the strictTypes option, but if strictTypes is true a non-zero positive status will be returned). The mapping of types supported by Datum to JSON types is described in Supported Types .

◆ encode() [6/6]

static int baljsn::DatumUtil::encode ( std::string *  result,
const bdld::Datum datum,
const DatumEncoderOptions options 
)
static

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