BDE 4.14.0 Production release
|
Modules | |
baljsn_datumdecoderoptions | |
Provide options for decoding JSON into a Datum object. | |
baljsn_datumencoderoptions | |
Provide an attribute class for specifying Datum<->JSON options. | |
baljsn_datumutil | |
Provide utilities converting between bdld::Datum and JSON data. | |
baljsn_decoder | |
Provide a JSON decoder for bdeat compatible types. | |
baljsn_decoderoptions | |
Provide an attribute class for specifying JSON decoding options. | |
baljsn_decoderoptionsutil | |
Provide a utility for configuring baljsn::DecoderOptions . | |
baljsn_encoder | |
Provide a JSON encoder for bdlat -compatible types. | |
baljsn_encoder_testtypes | |
Provide value-semantic attribute classes. | |
baljsn_encoderoptions | |
Provide an attribute class for specifying JSON encoding options. | |
baljsn_encodingstyle | |
Provide value-semantic attribute classes. | |
baljsn_formatter | |
Provide a formatter for encoding data in the JSON format. | |
baljsn_parserutil | |
Provide a utility for decoding JSON data into simple types. | |
baljsn_printutil | |
Provide a utility for encoding simple types in the JSON format. | |
baljsn_simpleformatter | |
Provide a simple formatter for encoding data in the JSON format. | |
baljsn_tokenizer | |
Provide a tokenizer for extracting JSON data from a streambuf . | |
Provide components for encoding/decoding in the JSON format.
Basic Application Library JSoN (baljsn)
The 'baljsn' package provides facilities for encoding and decoding value-semantic objects in the JSON encoding format. Currently, the encoder and decoder provided in this package work with types that support the 'bdeat' framework (see the {'bdlat'} package for details), which is a compile-time interface for manipulating struct-like and union-like objects.
The 'baljsn' package currently has 15 components having 5 levels of physical dependency. The list below shows the hierarchical ordering of the components. The order of components within each level is not architecturally significant, just alphabetical.
baljsn_datumdecoderoptions : Provide options for decoding JSON into a Datum
object.
baljsn_datumencoderoptions : Provide an attribute class for specifying Datum<->JSON options.
baljsn_datumutil : Provide utilities converting between bdld::Datum
and JSON data.
baljsn_decoder : Provide a JSON decoder for bdeat
compatible types.
baljsn_decoderoptions : Provide an attribute class for specifying JSON decoding options.
baljsn_decoderoptionsutil : Provide a utility for configuring baljsn::DecoderOptions
.
baljsn_encoder : Provide a JSON encoder for bdlat
-compatible types.
'baljsn_encoder_testtypes': !PRIVATE! Provide value-semantic attribute classes
baljsn_encoderoptions : Provide an attribute class for specifying JSON encoding options.
baljsn_encodingstyle : Provide value-semantic attribute classes.
baljsn_formatter : Provide a formatter for encoding data in the JSON format.
baljsn_parserutil : Provide a utility for decoding JSON data into simple types.
baljsn_printutil : Provide a utility for encoding simple types in the JSON format.
baljsn_simpleformatter : Provide a simple formatter for encoding data in the JSON format.
baljsn_tokenizer : Provide a tokenizer for extracting JSON data from a streambuf
.
The following table provides a mapping between an element's 'bdem' elem type (as specified in bdem_elemtype ), its XSD type, its C++ type, its corresponding JSON type, and the encoding used.
The format grammar specified below uses the Extended BNF notation (except that ',' is not used for concatenation to enhance readability). A quick reference of EBNF is provided below (refer here for more details):
(1) Double types (float, decimal, and double) are encoded in the number format by default with the values NaN, +INF and -INF resulting in an encoding error. These values can be printed as strings by setting the 'encodeInfAndNaNAsStrings' encoder option to 'true'.
(2) In practice only the timezone-enabled components are used by bcem_Aggregate and generated types. The supported format is a subset of the ISO 8601 standard. For further details refer to the bdepu_iso8601 component.
(3) Null values are not encoded on the wire by default. The 'encodeNullElements' options can be set to 'true' to ensure that null values are encoded.
(4) The name of an element corresponds to that element's name in the provided xsd.
The 'baljsn::DecoderOption' parameter of the 'decode' function has a configuration option named 'validateInputIsUtf8'. If this option is 'true', the 'decode' function will succeed only if the encoding of the JSON data is UTF-8, which the JSON specification requires. If the option is 'false', 'decode' will not validate that the encoding of the JSON data is UTF-8, and may succeed even if the data does not satisfy the UTF-8 validity requirement of the JSON specification. This option primarily affects the acceptance of string literals, which are the parts of JSON documents that may have rational justification for having non-UTF-8, and therefore invalid, content.
Ideally, users should set 'validateInputIsUtf8' to 'true'. However, some legacy applications currently might be trafficking in JSON that contains non-UTF-8 with no adverse effects to their clients. Consequently, this option is 'false' by default to maintain backward compatibility.