BloombergLP::bdljsn::Json

This type is designed to be a thin wrapper around a variant of the possible JSON types, using a BDE-style variant interface.

Synopsis

Declared in <bdljsn_json.h>

class Json;

Member Functions

NameDescription
Json [constructor]Constructors
operator= Assignment operators
allocator Return the allocator used by this object to allocate memory.
asDecimal64 Same as the related overload above for asDecimal64.
asDecimal64Exact Load the specified result with the closest floating point representation to the value of type JsonNumber held by this object, even if a non-zero status is returned. Return 0 if this number can be represented exactly, and return JsonNumber::k_INEXACT if value cannot be represented exactly. If this number is outside the representable range, load result with +INF or -INF (as appropriate). A number can be represented exactly as a Decimal64 if, for the significand and exponent, abs(significand) <= 9,999,999,999,999,999 and -398 <= exponent <= 369. The behavior is undefined unless isNumber() returns true;
asDouble Same as the related overload above for asDouble.
asFloat Return the closest floating point representation to the value of the type JsonNumber held by this object. If this number is outside the representable range, return +INF or -INF (as appropriate). The behavior is undefined unless isNumber() returns true.
asInt Same as the related overload above for asInt.
asInt64 Same as the related overload above for asInt64.
asLong Same as the overload taking int.
asLonglong Same as the related overload above for asLonglong.
asShort Load into the specified result the integer value of the value of type JsonNumber held by this object. Return 0 on success, JsonNumber::k_OVERFLOW if value is larger than can be represented by result, JsonNumber::k_UNDERFLOW if value is smaller than can be represented by result, and JsonNumber::k_NOT_INTEGRAL if value is not an integral number (i.e., there is a fractional part). For underflow, result will be loaded with the minimum representable value, for overflow, result will be loaded with the maximum representable value, for non-integral values result will be loaded with the integer part of value (truncating the value to the nearest integer). If the result is not an integer and also either overflows or underflows, it is treated as an overflow or underflow (respectively). Note that this operation returns a status value (unlike similar floating point conversions) because typically it is an error if a conversion to an integer results in an inexact value. The behavior is undefined unless isNumber() returns true. Also note that on all supported platforms bsls::Types::Int64 and bsls::Types::Uint64 are, respectively, aliases for long long and unsigned long long.
asUint Same as the related overload above for asUint.
asUint64 Same as the related overload above for asUint64.
asUlong Same as the overload taking unsigned int.
asUlonglong Same as the overload taking long long.
asUshort Same as the related overload above for asUshort.
contains Return true if the JsonObject held by this Json object contains a member whose key is equivalent to the specified key, and return false otherwise. The behavior is undefined unless true == isObject().
insert insert overloads
isArray Return true if the value held by this object is of type JsonArray, and false otherwise.
isBoolean Return true if the value held by this object is of type bool, and false otherwise.
isNull Return true if the value held by this object is of type JsonNull, and false otherwise.
isNumber Return true if the value held by this object is of type JsonNumber, and false otherwise.
isObject Return true if the value held by this object is of type JsonObject, and false otherwise.
isString Return true if the value held by this object is of type bsl::string, and false otherwise.
makeArray makeArray overloads
makeBoolean makeBoolean overloads
makeNull Create an instance of type JsonNull in this object. This method first destroys the current value held by this object.
makeNumber makeNumber overloads
makeObject makeObject overloads
makeString makeString overloads
operator[] Subscript operators
print Write the value of this object to the specified output stream in a human-readable format, and return a reference to stream. Optionally specify an initial indentation level, whose absolute value is incremented recursively for nested objects. If level is specified, optionally specify spacesPerLevel, whose absolute value indicates the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect. Note that this human-readable format is not fully specified, and can change without notice.
pushBack pushBack overloads
size Return the number of elements in the JsonObject or JsonArray held by this object. The behavior is undefined unless isArray() || isObject() evaluates to true.
swap Exchange the value of this with that of the specified other. If an exception is thrown, both objects are left in valid but unspecified states. This operation guarantees O[1]complexity. The behavior is undefined unless this object was created with the same allocator as other.
theArray theArray overloads
theBoolean theBoolean overloads
theNull theNull overloads
theNumber theNumber overloads
theObject theObject overloads
theString Return a reference providing non-modifiable access to the value of type JsonString held by this object. The behavior is undefined unless isString() returns true.
type Return the type of this Json value.
visit visit overloads
operator BloombergLP::bslmf::NestedTraitDeclaration<Json, HasPrintMethod> Declare nested type traits for this type.
operator JsonArray& Return a reference providing modifiable access to the value of type JsonArray held by this object. The behavior is undefined unless isArray() returns true.
operator JsonNull& Return a reference providing modifiable access to the value of type JsonNull held by this object. The behavior is undefined unless isNull() returns true.
operator JsonNumber& Return a reference providing modifiable access to the value of type JsonNumber held by this object. The behavior is undefined unless isNumber() returns true.
operator JsonObject& Return a reference providing modifiable access to the value of type JsonObject held by this object. The behavior is undefined unless isObject() returns true.
operator bool& Return a reference providing modifiable access to the value of type boolean held by this object. The behavior is undefined unless isBoolean() returns true.
operator JsonArray const& Return a reference providing non-modifiable access to the value of type JsonArray held by this object. The behavior is undefined unless isArray() returns true.
operator JsonNull const& Return a reference providing non-modifiable access to the value of type JsonNull held by this object. The behavior is undefined unless isNull() returns true.
operator JsonNumber const& Return a reference providing non-modifiable access to the value of type JsonNumber held by this object. The behavior is undefined unless isNumber() returns true.
operator JsonObject const& Return a reference providing non-modifiable access to the value of type JsonObject held by this object. The behavior is undefined unless isObject() returns true.
operator bool const& Return a reference providing non-modifiable access to the value of type boolean held by this object. The behavior is undefined unless isBoolean() returns true.
operator bsl::string const& Return a reference providing non-modifiable access to the value of type JsonString held by this object. The behavior is undefined unless isString() returns true.

Friends

NameDescription
BloombergLP::bdljsn::swapExchange the value of the specified a Json object with that of the specified b Json object. If an exception is thrown, both objects are left in valid but unspecified states. This operation guarantees O[1] complexity. The behavior is undefined unless a was created with the same allocator as b.
BloombergLP::bdljsn::operator!=Return false if the specified lhs and rhs objects have the same value, and true otherwise. Two Json objects lhs and rhs have the same value if they hold objects of the same type, and those objects have the same value.
BloombergLP::bdljsn::operator==Return true if the specified lhs and rhs objects have the same value, and false otherwise. Two Json objects lhs and rhs have the same value if they hold objects of the same type, and those objects have the same value.

Non-Member Functions

NameDescription
operator!=Same as the related overload above for operator!=.
operator!=Same as the related overload above for operator!=.
operator!=Same as the related overload above for operator!=.
operator!=Same as the related overload above for operator!=.
operator!=Return true if the specified lhs and rhs do not have the same value.
operator!=Same as the related overload above for operator!=.
operator!=Same as the related overload above for operator!=.
operator!=Same as the related overload above for operator!=.
operator!=Same as the related overload above for operator!=.
operator!=Same as the related overload above for operator!=.
operator!=Same as the related overload above for operator!=.
operator!=Process the specified array during visitation of a bdljsn::Json object.
operator!=Same as the related overload above for operator!=.
operator!=Same as the related overload above for operator!=.
operator!=Same as the related overload above for operator!=.
operator!=Same as the related overload above for operator!=.
operator""_jsonReturn a bdljsn::Json object having the value of the JSON described in the specified text of the specified numBytes. If text is not a valid JSON document then invoke the currently installed bsls::Assert failure handler.
operator==Same as the related overload above for operator==.
operator==Process the specified object during visitation of a bdljsn::Json object.
operator==Same as the related overload above for operator==.
operator==Same as the related overload above for operator==.
operator==Same as the related overload above for operator==.
operator==Same as the related overload above for operator==.
operator==Same as the related overload above for operator==.
operator==Same as the related overload above for operator==.
operator==Same as the related overload above for operator==.
operator==Same as the related overload above for operator==.
operator==Same as the related overload above for operator==.
operator==Same as the related overload above for operator==.
operator==Same as the related overload above for operator==.
operator==Same as the related overload above for operator==.
operator==Same as the related overload above for operator==.
operator==Process the specified array during visitation of a bdljsn::Json object.