Quick Links:

bal | bbl | bdl | bsl

Namespaces

Component bdljsn_jsontype
[Package bdljsn]

Enumerate the set of JSON value types. More...

Namespaces

namespace  bdljsn

Detailed Description

Outline
Purpose:
Enumerate the set of JSON value types.
Classes:
bdljsn::JsonType namespace for a enum of JSON value types
See also:
Component bdljsn_json, Component bdljsn_jsonutil, bdljsn_jsonvalue
Description:
This component provides a namespace for the enum type bdljsn::JsonType::Enum, which enumerates the set of fundamental JSON types in the JSON specification (see http://json.org).
Enumerators:
  Name            Description
  -------------   ---------------------------------------------------
  e_OBJECT        A JSON object
  e_ARRAY         A JSON array
  e_STRING        A JSON string
  e_NUMBER        A JSON number
  e_BOOLEAN       true or false
  e_NULL          null
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::JsonType.
First, we create a variable value of type bdljsn::JsonType::Enum and initialize it with the enumerator value bdljsn::JsonType::e_STRING:
  bdljsn::JsonType::Enum value = bdljsn::JsonType::e_STRING;
Now, we store the address of its ASCII representation in a pointer variable, asciiValue, of type const char *:
  const char *asciiValue = bdljsn::JsonType::toAscii(value);
  assert(0 == bsl::strcmp(asciiValue, "STRING"));
Finally, we print value to bsl::cout.
  bsl::cout << value << bsl::endl;
This statement produces the following output on stdout:
  STRING