|
BDE 4.14.0 Production release
|
#include <bdljsn_json.h>
Friends | |
| bool | operator== (const Json &, const Json &) |
| bool | operator!= (const Json &, const Json &) |
| template<class HASHALG > | |
| void | hashAppend (HASHALG &, const Json &) |
| void | swap (Json &, Json &) |
This type is designed to be a thin wrapper around a variant of the possible JSON types, using a BDE-style variant interface.
See bdljsn_json
|
inline |
|
inlineexplicit |
|
inline |
Create a Json object having the same value as the specified original. Optionally specify the basicAllocator used to supply memory. If basicAllocator is not specified, the currently installed default allocator is used to supply memory.
|
inline |
Create a Json object having the same value as the specified original object by moving (in constant time) the contents of original to the new JsonObject. The allocator associated with original is propagated for use in the newly-created Json object. original is left in a valid but unspecified state.
|
inline |
Create a Json object having the same value as the specified original. Use the specified basicAllocator to supply memory.
|
inlineexplicit |
|
inlineexplicit |
Create a Json object having the type JsonArray and the same value as the specified array object by moving (in constant time) the contents of array to the new Json object. Optionally specify the basicAllocator used to supply memory. If basicAllocator is not specified, the allocator associated with array is propagated for use in the newly-created Json object. array is left in a valid but unspecified state.
|
inlineexplicit |
Create a Json object having the type bool and the same value as the specified boolean. Optionally specify the basicAllocator used to supply memory. If basicAllocator is not specified, the currently installed default allocator is used to supply memory.
|
inlineexplicit |
|
inlineexplicit |
|
inlineexplicit |
|
inlineexplicit |
|
inlineexplicit |
|
inlineexplicit |
|
inlineexplicit |
|
inlineexplicit |
|
inlineexplicit |
Create a Json object having the type JsonNumber and the same value as the specified number. Optionally specify the basicAllocator used to supply memory. If basicAllocator is not specified, the currently installed default allocator is used to supply memory.
|
inlineexplicit |
Create a Json object having the type JsonNumber and the same value as the specified number object by moving (in constant time) the contents of number to the new Json object. Optionally specify the basicAllocator used to supply memory. If basicAllocator is not specified, the allocator associated with number is propagated for use in the newly-created Json object. number is left in a valid but unspecified state.
|
inlineexplicit |
Create a Json object having the type JsonObject and the same value as the specified object. Optionally specify the basicAllocator used to supply memory. If basicAllocator is not specified, the currently installed default allocator is used to supply memory.
|
inlineexplicit |
Create a Json object having the type JsonObject and the same value as the specified object by moving (in constant time) the contents of object to the new Json object. Optionally specify the basicAllocator used to supply memory. If basicAllocator is not specified, the allocator associated with object is propagated for use in the newly-created Json object. object is left in a valid but unspecified state.
|
inlineexplicit |
|
inlineexplicit |
Create a Json object having the type bsl::string and the same value as the specified string. Optionally specify the basicAllocator used to supply memory. If basicAllocator is not specified, the currently installed default allocator is used to supply memory. The behavior is undefined unless string is valid UTF-8 (see bdlde::Utf8Util::isValid).
|
inlineexplicit |
Create a Json object having the type bsl::string and the same value as the specified string by moving (in constant time) the contents of string to the new Json object. Optionally specify the basicAllocator used to supply memory. If basicAllocator is not specified, the allocator associated with string is propagated for use in the newly-created Json object. string is left in a valid but unspecified state. This function does not participate in overload resolution unless the specified STRING_TYPE is bsl::string. The behavior is undefined unless string is valid UTF-8 (see bdlde::Utf8Util::isValid).
|
inline |
|
inline |
|
inline |
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;
|
inline |
|
inline |
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.
|
inline |
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.
|
inline |
|
inline |
|
inline |
| bdljsn::Json::BSLMF_NESTED_TRAIT_DECLARATION | ( | Json | , |
| bdlb::HasPrintMethod | |||
| ) |
| bdljsn::Json::BSLMF_NESTED_TRAIT_DECLARATION | ( | Json | , |
| bslma::UsesBslmaAllocator | |||
| ) |
| bdljsn::Json::BSLMF_NESTED_TRAIT_DECLARATION | ( | Json | , |
| bslmf::IsBitwiseMoveable | |||
| ) |
|
inline |
Return true if the value held by this object is of type JsonArray, and false otherwise.
|
inline |
Return true if the value held by this object is of type bool, and false otherwise.
|
inline |
Return true if the value held by this object is of type JsonNull, and false otherwise.
|
inline |
Return true if the value held by this object is of type JsonNumber, and false otherwise.
|
inline |
Return true if the value held by this object is of type JsonObject, and false otherwise.
|
inline |
Return true if the value held by this object is of type bsl::string, and false otherwise.
|
inline |
Create an instance of type JsonArray in this object, using the allocator currently held by this object to supply memory, and return a reference providing modifiable access to the created instance. Optionally specify array to initialize the JsonArray created. This method first destroys the current value held by this object (even if the type currently held is JsonArray).
|
inline |
|
inline |
Create an instance of type bool in this object and return a reference providing modifiable access to the created instance. Optionally specify boolean to initialize the bool created. This method first destroys the current value held by this object.
|
inline |
|
inline |
Create an instance of type JsonNull in this object. This method first destroys the current value held by this object.
|
inline |
Create an instance of type JsonNumber in this object, using the allocator currently held by this object to supply memory, and return a reference providing modifiable access to the created instance. Optionally specify number to initialize the JsonNumber created. This method first destroys the current value held by this object (even if the type currently held is JsonNumber).
|
inline |
|
inline |
|
inline |
Create an instance of type JsonObject in this object, using the allocator currently held by this object to supply memory, and return a reference providing modifiable access to the created instance. Optionally specify object to initialize the JsonObject created. This method first destroys the current value held by this object (even if the type currently held is JsonObject).
|
inline |
|
inline |
|
inline |
Create an instance of type bsl::string in this object, using the allocator currently held by this object to supply memory. Optionally specify string to initialize the bsl::string created. This method first destroys the current value held by this object (even if the type currently held is bsl::string). This function does not participate in overload resolution unless the specified STRING_TYPE is bsl::string. The behavior is undefined unless string is valid UTF-8 (see bdlde::Utf8Util::isValid).
|
inline |
Create an instance of type bsl::string in this object, using the allocator currently held by this object to supply memory. Optionally specify string to initialize the bsl::string created. This method first destroys the current value held by this object (even if the type currently held is bsl::string). The behavior is undefined unless string is valid UTF-8 (see bdlde::Utf8Util::isValid).
|
inline |
|
inline |
|
inline |
Assign to this object a value of type bool initialized from the specified rhs, and return a reference providing modifiable access to this object. The value currently held by this object (if any) is destroyed if that value's type is not bsl::string.
|
inline |
Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object. The contents of rhs are moved (in constant time) to this Json object if allocator() == rhs.allocator(); otherwise they are copied. rhs is left in a valid but unspecified state.
|
inline |
Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object. The contents of rhs are moved (in constant time) to this Json object if allocator() == rhs.allocator(); otherwise, they are copied. rhs is left in a valid but unspecified state. The value currently held by this object (if any) is destroyed if that value's type is not JsonArray.
|
inline |
|
inline |
Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object. The contents of rhs are moved (in constant time) to this Json object if allocator() == rhs.allocator(); otherwise, they are copied. rhs is left in a valid but unspecified state. The value currently held by this object (if any) is destroyed if that value's type is not JsonNumber.
|
inline |
Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object. The contents of rhs are moved (in constant time) to this Json object if allocator() == rhs.allocator(); otherwise, they are copied. rhs is left in a valid but unspecified state. The value currently held by this object (if any) is destroyed if that value's type is not JsonObject.
| bsl::enable_if< bsl::is_same< STRING_TYPE, bsl::string >::value, Json >::type & bdljsn::Json::operator= | ( | BSLMF_MOVABLEREF_DEDUCE(STRING_TYPE) | rhs | ) |
Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object. The contents of rhs are moved (in constant time) to this Json object if allocator() == rhs.allocator(); otherwise, they are copied. rhs is left in a valid but unspecified state. The value currently held by this object (if any) is destroyed if that value's type is not bsl::string. This function does not participate in overload resolution unless the specified STRING_TYPE is bsl::string. The behavior is undefined unless rhs is valid UTF-8 (see bdlde::Utf8Util::isValid).
|
inline |
|
inline |
|
inline |
|
inline |
Assign to this object a value of type bsl::string initialized from the specified rhs, and return a reference providing modifiable access to this object. The value currently held by this object (if any) is destroyed if that value's type is not bsl::string. The behavior is undefined unless rhs is valid UTF-8 (see bdlde::Utf8Util::isValid).
Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object. The value currently held by this variant is destroyed if that value's type is not the same as the type held by the rhs object.
|
inline |
|
inline |
Assign to this object a value of type JsonObject initialized from the specified rhs, and return a reference providing modifiable access to this object. The value currently held by this object (if any) is destroyed if that value's type is not JsonObject.
|
inline |
|
inline |
Assign to this object a value of type JsonNumber initialized from the specified rhs, and return a reference providing modifiable access to this object. The value currently held by this object (if any) is destroyed if that value's type is not JsonNumber.
|
inline |
|
inline |
|
inline |
Return a reference providing modifiable access to the element at the specified index in the JsonArray held by this object. The behavior is undefined unless isArray() returns true and index < theArray().size().
|
inline |
Return a reference providing non-modifiable access to the element at the specified index in the JsonArray held by this object. The behavior is undefined unless isArray() returns true and index < theArray().size().
|
inline |
Return a reference providing modifiable access to the Json object associated with the specified key in the JsonObject held by this object; if the JsonObject does not already contain a Json object associated with key, first insert a new default-constructed Json object associated with key. The behavior is undefined unless isObject() returns true.
|
inline |
Return a reference providing non-modifiable access to the Json object associated with the specified key in this JsonObject. The behavior is undefined unless key is valid UTF-8 (see bdlde::Utf8Util::isValid) and this JsonObject already contains a Json object associated with key.
| bsl::ostream & bdljsn::Json::print | ( | bsl::ostream & | stream, |
| int | level = 0, |
||
| int | spacesPerLevel = 4 |
||
| ) | const |
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.
|
inline |
Return the number of elements in the JsonObject or JsonArray held by this object. The behavior is undefined unless isArray() || isObject() evaluates to true.
|
inline |
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.
|
inline |
|
inline |
|
inline |
Return a reference providing modifiable access to the value of type boolean held by this object. The behavior is undefined unless isBoolean() returns true.
|
inline |
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.
|
inline |
|
inline |
|
inline |
Return a reference providing modifiable access to the value of type JsonNumber held by this object. The behavior is undefined unless isNumber() returns true.
|
inline |
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.
|
inline |
Return a reference providing modifiable access to the value of type JsonObject held by this object. The behavior is undefined unless isObject() returns true.
|
inline |
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.
|
inline |
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.
|
inline |
|
friend |
Invoke the specified hashAlg on the attributes of the specified object.
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.
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.