|
BDE 4.39.x Production Release
|
Provide a utility to encode bdlat-compatible types as JSON.
Provide a utility to encode bdlat-compatible types as JSON.
bdlat-compliant typesThis component provides a utility struct template, baljsn::EncodeImplUtil that provides functions that determine the value of bdlat-compatible value-semantic objects and represents those values in a JSON format. The exact form of that representation is determined by template parameterFORMATTER. In particular, the struct contains a encode function parameterized on TYPE that encodes an object into a specified stream. There are two overloaded versions of this function:
bsl::streambufbsl::ostreamThis component can be used with types that support the bdlat framework (see the bdlat package for details), which is a compile-time interface for manipulating struct-like and union-like objects. In particular, types generated by the bas_codegen.pl tool, and other dynamic types, can be encoded using this class. The encode function can be invoked on any object that satisfies the requirements of a sequence, choice, or array object as defined in the bdlat_sequencefunctions , bdlat_choicefunctions , and bdlat_arrayfunctions components.
Although the JSON format is easy to read and write and is very useful for debugging, it is relatively expensive to encode and decode and relatively bulky to transmit. It is more efficient to use a binary encoding (such as BER) if the encoding format is under your control (see balber_berencoder ).
Refer to the details of the JSON encoding format supported by this encoder in the package documentation file (doc/baljsn.txt).
This section illustrates intended use of this component.