Quick Links:

bal | bbl | bdl | bsl

Namespaces

Component bdljsn_writestyle
[Package bdljsn]

Enumerate the formatting styles for a writing a JSON document. More...

Namespaces

namespace  bdljsn

Detailed Description

Outline
Purpose:
Enumerate the formatting styles for a writing a JSON document.
Classes:
bdljsn::WriteStyle namespace for styles for writing a JSON document
See also:
Component bdljsn_writeoptions
Description:
This component provides bdljsn::WriteStyle, a namespace for the enum type bdljsn::WriteStyle::Enum, which enumerates the set of format styles that can be used when writing a JSON document.
Enumerators:
  Name              Description
  -------------     -------------------------------------------------------
  e_PRETTY          A human friendly format with configurable new lines and
                    indentation

  e_ONELINE         A single-line format with a space after each comma and
                    colon.

  e_COMPACT         A maximally compact format with no white space.
Usage:
This section illustrates intended use of this component.
Example 1: Basic Syntax:
The following snippets of code provide a simple illustration of using bdljsn::WriteStyle.
First, we create a variable value of type bdljsn::WriteStyle::Enum and initialize it with the enumerator value bdljsn::WriteStyle::e_PRETTY:
  bdljsn::WriteStyle::Enum value = bdljsn::WriteStyle::e_PRETTY;
Now, we store the address of its ASCII representation in a pointer variable, asciiValue, of type const char *:
  const char *asciiValue = bdljsn::WriteStyle::toAscii(value);
  assert(0 == bsl::strcmp(asciiValue, "PRETTY"));
Finally, we print value to bsl::cout.
  bsl::cout << value << bsl::endl;
This statement produces the following output on stdout:
  PRETTY