|
BDE 4.39.x Production Release
|
#include <bdljsn_json.h>
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
Public Member Functions | |
| BSLMF_NESTED_TRAIT_DECLARATION (Json, bslma::UsesBslmaAllocator) | |
| BSLMF_NESTED_TRAIT_DECLARATION (Json, bslmf::IsBitwiseMoveable) | |
| BSLMF_NESTED_TRAIT_DECLARATION (Json, bdlb::HasPrintMethod) | |
| Json () | |
| Json (bslma::Allocator *basicAllocator) | |
| Json (const Json &original, bslma::Allocator *basicAllocator=0) | |
| Json (bslmf::MovableRef< Json > original) | |
| Json (bslmf::MovableRef< Json > original, bslma::Allocator *basicAllocator) | |
| Json (bool boolean, bslma::Allocator *basicAllocator=0) | |
| Json (const JsonNull &null, bslma::Allocator *basicAllocator=0) | |
| Json (const JsonArray &array, bslma::Allocator *basicAllocator=0) | |
| Json (const JsonObject &object, bslma::Allocator *basicAllocator=0) | |
| Json (const JsonNumber &number, bslma::Allocator *basicAllocator=0) | |
| Json (bslmf::MovableRef< JsonArray > array, bslma::Allocator *basicAllocator=0) | |
| Json (bslmf::MovableRef< JsonObject > object, bslma::Allocator *basicAllocator=0) | |
| Json (bslmf::MovableRef< JsonNumber > number, bslma::Allocator *basicAllocator=0) | |
| Json (int value, bslma::Allocator *basicAllocator=0) | |
| Json (unsigned int value, bslma::Allocator *basicAllocator=0) | |
| Json (long value, bslma::Allocator *basicAllocator=0) | |
| Json (unsigned long value, bslma::Allocator *basicAllocator=0) | |
| Json (long long value, bslma::Allocator *basicAllocator=0) | |
| Json (unsigned long long value, bslma::Allocator *basicAllocator=0) | |
| Json (float value, bslma::Allocator *basicAllocator=0) | |
| Json (double value, bslma::Allocator *basicAllocator=0) | |
| Json (bdldfp::Decimal64 value, bslma::Allocator *basicAllocator=0) | |
| Json (const char *string, bslma::Allocator *basicAllocator=0) | |
| Json (const bsl::string_view &string, bslma::Allocator *basicAllocator=0) | |
| template<class t_STRING_TYPE > | |
| Json (BSLMF_MOVABLEREF_DEDUCE(t_STRING_TYPE) string, bslma::Allocator *basicAllocator=0, typename bsl::enable_if< bsl::is_same< t_STRING_TYPE, bsl::string >::value >::type *=0) | |
| Json & | operator= (const Json &rhs) |
| Json & | operator= (bslmf::MovableRef< Json > rhs) |
| Json & | operator= (const JsonNumber &rhs) |
| Json & | operator= (int rhs) |
| Json & | operator= (unsigned int rhs) |
| Json & | operator= (long rhs) |
| Json & | operator= (unsigned long rhs) |
| Json & | operator= (long long rhs) |
| Json & | operator= (unsigned long long rhs) |
| Json & | operator= (float rhs) |
| Json & | operator= (double rhs) |
| Json & | operator= (bdldfp::Decimal64 rhs) |
| Json & | operator= (bslmf::MovableRef< JsonNumber > rhs) |
| Json & | operator= (const char *rhs) |
| Json & | operator= (const bsl::string_view &rhs) |
| template<class t_STRING_TYPE > | |
| bsl::enable_if< bsl::is_same< t_STRING_TYPE, bsl::string >::value, Json >::type & | operator= (BSLMF_MOVABLEREF_DEDUCE(t_STRING_TYPE) rhs) |
| Json & | operator= (bool rhs) |
| Json & | operator= (const JsonObject &rhs) |
| Json & | operator= (bslmf::MovableRef< JsonObject > rhs) |
| Json & | operator= (const JsonArray &rhs) |
| Json & | operator= (bslmf::MovableRef< JsonArray > rhs) |
| Json & | operator= (const JsonNull &) |
| Json & | operator= (bslmf::MovableRef< JsonNull >) |
| JsonArray & | makeArray () |
| JsonArray & | makeArray (const JsonArray &array) |
| JsonArray & | makeArray (bslmf::MovableRef< JsonArray > array) |
| bool & | makeBoolean () |
| bool & | makeBoolean (bool boolean) |
| void | makeNull () |
| JsonNumber & | makeNumber () |
| JsonNumber & | makeNumber (const JsonNumber &number) |
| JsonNumber & | makeNumber (bslmf::MovableRef< JsonNumber > number) |
| JsonObject & | makeObject () |
| JsonObject & | makeObject (const JsonObject &object) |
| JsonObject & | makeObject (bslmf::MovableRef< JsonObject > object) |
| void | makeString (const char *string) |
| void | makeString (const bsl::string_view &string) |
| template<class t_STRING_TYPE > | |
| bsl::enable_if< bsl::is_same< t_STRING_TYPE, bsl::string >::value >::type | makeString (BSLMF_MOVABLEREF_DEDUCE(t_STRING_TYPE) string) |
| JsonArray & | theArray () |
| bool & | theBoolean () |
| JsonNull & | theNull () |
| JsonNumber & | theNumber () |
| JsonObject & | theObject () |
| Json & | operator[] (const bsl::string_view &key) |
| Json & | operator[] (bsl::size_t index) |
| bsl::pair< JsonObject::Iterator, bool > | insert (const JsonObject::Member &member) |
| bsl::pair< JsonObject::Iterator, bool > | insert (bslmf::MovableRef< JsonObject::Member > member) |
| template<class t_INPUT_ITERATOR > | |
| bsl::enable_if<!bsl::is_convertible< t_INPUT_ITERATOR, bsl::string_view >::value, Json & >::type | insert (t_INPUT_ITERATOR first, t_INPUT_ITERATOR last) |
| template<class t_VALUE , class t_STRING_VIEW > | |
| bsl::enable_if<!bsl::is_integral< t_STRING_VIEW >::value &&bsl::is_convertible< t_STRING_VIEW, bsl::string_view >::value, bsl::pair< JsonObject::Iterator, bool > >::type | insert (const t_STRING_VIEW &key, BSLS_COMPILERFEATURES_FORWARD_REF(t_VALUE) value) |
| template<class t_INDEX > | |
| bsl::enable_if< bsl::is_integral< t_INDEX >::value &&!bsl::is_same< t_INDEX, bool >::value, JsonArray::Iterator >::type | insert (t_INDEX index, const Json &json) |
| template<class t_INDEX > | |
| bsl::enable_if< bsl::is_integral< t_INDEX >::value &&!bsl::is_same< t_INDEX, bool >::value, JsonArray::Iterator >::type | insert (t_INDEX index, bslmf::MovableRef< Json > json) |
| template<class t_INDEX , class t_INPUT_ITERATOR > | |
| bsl::enable_if< bsl::is_integral< t_INDEX >::value &&!bsl::is_same< t_INDEX, bool >::value, JsonArray::Iterator >::type | insert (t_INDEX index, t_INPUT_ITERATOR first, t_INPUT_ITERATOR last) |
| JsonArray::Iterator | insert (JsonArray::ConstIterator position, const Json &json) |
| JsonArray::Iterator | insert (JsonArray::ConstIterator position, bslmf::MovableRef< Json > json) |
| template<class t_INPUT_ITERATOR > | |
| JsonArray::Iterator | insert (JsonArray::ConstIterator position, t_INPUT_ITERATOR first, t_INPUT_ITERATOR last) |
| Json & | pushBack (const Json &json) |
| Json & | pushBack (const JsonArray &array) |
| Json & | pushBack (const JsonObject &object) |
| Json & | pushBack (const JsonNumber &number) |
| Json & | pushBack (bslmf::MovableRef< Json > json) |
| Json & | pushBack (bslmf::MovableRef< JsonArray > array) |
| Json & | pushBack (bslmf::MovableRef< JsonObject > object) |
| Json & | pushBack (bslmf::MovableRef< JsonNumber > number) |
| Json & | pushBack (const JsonNull &value) |
| Json & | pushBack (bool value) |
| Json & | pushBack (int value) |
| Json & | pushBack (unsigned int value) |
| Json & | pushBack (long value) |
| Json & | pushBack (unsigned long value) |
| Json & | pushBack (long long value) |
| Json & | pushBack (unsigned long long value) |
| Json & | pushBack (float value) |
| Json & | pushBack (double value) |
| Json & | pushBack (bdldfp::Decimal64 value) |
| Json & | pushBack (const char *string) |
| Json & | pushBack (const bsl::string_view &string) |
| template<class t_STRING_TYPE > | |
| bsl::enable_if< bsl::is_same< t_STRING_TYPE, bsl::string >::value, Json & >::type | pushBack (BSLMF_MOVABLEREF_DEDUCE(t_STRING_TYPE) string) |
| template<class RETURN_TYPE , class VISITOR > | |
| RETURN_TYPE | visit (BSLS_COMPILERFEATURES_FORWARD_REF(VISITOR) visitor) |
| void | swap (Json &other) |
| int | asShort (short *result) const |
| int | asInt (int *result) const |
| int | asLong (long *result) const |
| int | asLonglong (long long *result) const |
| int | asInt64 (bsls::Types::Int64 *result) const |
| int | asUshort (unsigned short *result) const |
| int | asUint (unsigned int *result) const |
| int | asUlong (unsigned long *result) const |
| int | asUlonglong (unsigned long long *result) const |
| int | asUint64 (bsls::Types::Uint64 *result) const |
| float | asFloat () const |
| double | asDouble () const |
| bdldfp::Decimal64 | asDecimal64 () const |
| int | asDecimal64Exact (bdldfp::Decimal64 *result) const |
| bool | isArray () const |
| bool | isBoolean () const |
| bool | isNull () const |
| bool | isNumber () const |
| bool | isObject () const |
| bool | isString () const |
| const JsonArray & | theArray () const |
| const bool & | theBoolean () const |
| const JsonNull & | theNull () const |
| const JsonNumber & | theNumber () const |
| const JsonObject & | theObject () const |
| const bsl::string & | theString () const |
| JsonType::Enum | type () const BSLS_KEYWORD_NOEXCEPT |
| const Json & | operator[] (const bsl::string_view &key) const |
| const Json & | operator[] (bsl::size_t index) const |
| bsl::size_t | size () const |
| bool | contains (const bsl::string_view &key) const |
| template<class RETURN_TYPE , class VISITOR > | |
| RETURN_TYPE | visit (BSLS_COMPILERFEATURES_FORWARD_REF(VISITOR) visitor) const |
| bslma::Allocator * | allocator () const BSLS_KEYWORD_NOEXCEPT |
| bsl::ostream & | print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const |
Friends | |
| bool | operator== (const Json &, const Json &) |
| bool | operator!= (const Json &, const Json &) |
| void | swap (Json &, 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 |
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 |
|
inline |
Create a Json object having the type JsonArray/JsonObject/ JsonNumber and the value of the specified array/object/number. Optionally specify basicAllocator used to supply memory. If basicAllocator is not specified, the currently installed default allocator is used to supply memory.
|
inline |
|
inlineexplicit |
|
inline |
Create a Json object having the type JsonArray/JsonObject/ JsonNumber and the value of the specified array/object/ number object by moving the contents of array/object/number to the new object. Optionally specify basicAllocator used to supply memory. If basicAllocator is not specified, the allocator associated with array/object/number is propagated for use in the newly-created Json object. The allocator or array/object/ number is unchanged and is otherwise left in (valid) unspecified state.
|
inline |
|
inlineexplicit |
|
inlineexplicit |
Create a Json object having the type JsonNumber and the the specified value. 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 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.
string is valid UTF-8 (see bdlde::Utf8Util::isValid).
|
inlineexplicit |
|
inline |
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 t_STRING_TYPE is bsl::string.
string is valid UTF-8 (see bdlde::Utf8Util::isValid).
|
inline |
Return the allocator used by this object to allocate memory.
|
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.
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).
isNumber() returns true.
|
inline |
|
inline |
|
inline |
|
inline |
|
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).
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.
|
inline |
|
inline |
|
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 JsonObject held by this Json object contains a member whose key is equivalent to the specified key, and return false otherwise.
true == isObject().
|
inline |
Insert the specified move-insertable member into the JsonObject held by this object if the key of member does not already exist; otherwise, this method has no effect. Return a pair whose first member is an iterator referring to the (possibly newly inserted) Member object whose key matches, and whose second member is true if a new value was inserted, and false otherwise. member is left in a valid but unspecified state. If isNull(), then the type is changed to object.
isObject() or isNull(), and unless member.first is valid UTF-8 (see bdlde::Utf8Util::isValid).
|
inline |
Insert the specified member into the JsonObject held by this object if the key of member does not already exist; otherwise, this method has no effect. Return a pair whose first member is an iterator referring to the (possibly newly inserted) Member object whose key matches, and whose second member is true if a new value was inserted, and false otherwise. If isNull(), then the type is changed to object.
isObject() or isNull(), and unless member.first is valid UTF-8 (see bdlde::Utf8Util::isValid).
|
inline |
Insert into the JsonObject held by this object a Member constructed from the specified key and value if key does not already exist; otherwise, this method has no effect. Return a pair whose first member is an iterator referring to the (possibly newly inserted) Member object whose key matches, and whose second member is true if a new value was inserted, and false otherwise. If isNull(), then the type is changed to object. The (template parameter) type t_STRING_VIEW must be convertible to bsl::string_view.
isObject() or isNull(), and unless key is valid UTF-8 (see bdlde::Utf8Util::isValid).
|
inline |
Insert into the JsonArray held by this object at the specified position the specified move-insertable json, and return an iterator referring to the newly inserted element. json is left in a valid but unspecified state. If an exception is thrown, *this is unaffected. Throw bsl::length_error if size() == maxSize().
isArray() and position is in the range [theArray().begin() .. theArray().end()].
|
inline |
Insert into the JsonArray held by this object at the specified position a copy of the specified json, and return an iterator referring to the newly inserted element. If an exception is thrown, *this is unaffected. Throw bsl::length_error if size() == maxSize().
isArray() and position is in the range [theArray().begin() .. theArray().end()].
|
inline |
Insert into the JsonArray held by this object at the specified position the values in the range [first, last), and return an iterator referring to the first newly inserted element. If an exception is thrown, *this is unaffected. Throw bsl::length_error if size() + distance(first, last) > maxSize().
isArray() and position is in the range [theArray().begin() .. theArray().end()].
|
inline |
Insert into the JsonArray held by this object at the specified index the specified move-insertable json, and return an iterator referring to the newly inserted element. json is left in a valid but unspecified state. If isNull(), then the type is changed to array and index must be 0. If an exception is thrown, *this is unaffected. Throw bsl::length_error if size() == maxSize(). The (template parameter) type t_INDEX must be a non-bool integral type.
|
inline |
Insert into the JsonArray held by this object at the specified index a copy of the specified json, and return an iterator referring to the newly inserted element. If isNull(), then the type is changed to array and index must be 0. If an exception is thrown, *this is unaffected. Throw bsl::length_error if size() == maxSize(). The (template parameter) type t_INDEX must be a non-bool integral type.
|
inline |
Insert into the JsonArray held by this object at the specified index the values in the range [first, last), and return an iterator referring to the first newly inserted element. If isNull(), then the type is changed to array and index must be 0. If an exception is thrown, *this is unaffected. Throw bsl::length_error if size() + distance(first, last) > maxSize(). The (template parameter) type t_INDEX must be a non-bool integral type.
|
inline |
Insert into the JsonObject held by this object each Member in the range [first, last) whose key is not already present. Return a non-const reference to this object. If isNull(), then the type is changed to object.
isObject() or isNull(), first and last refer to a valid sequence, and the keys of all members are valid UTF-8 (see bdlde::Utf8Util::isValid).
|
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 t_STRING_TYPE is bsl::string.
string is valid UTF-8 (see bdlde::Utf8Util::isValid).
|
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).
string is valid UTF-8 (see bdlde::Utf8Util::isValid).
|
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 bool.
|
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< t_STRING_TYPE, bsl::string >::value, Json >::type & bdljsn::Json::operator= | ( | BSLMF_MOVABLEREF_DEDUCE(t_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 t_STRING_TYPE is bsl::string.
rhs is valid UTF-8 (see bdlde::Utf8Util::isValid).
|
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.
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 |
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 |
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 |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Return a reference providing modifiable access to the element at the specified index in the JsonArray held by this object.
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.
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 isNull(), then type is changed to 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.
isObject() or isNull().
|
inline |
Return a reference providing non-modifiable access to the Json object associated with the specified key in this JsonObject.
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.
|
inline |
|
inline |
|
inline |
Append to the end of this Json object's array the specified move-insertable json/array/object/number and return a non-const reference to this object. json/array/object/number is left in a valid but unspecified state. If isNull, then the type is changed to array. If an exception is thrown, *this is unaffected. Throw bsl::length_error if size() == maxSize().
|
inline |
|
inline |
|
inline |
|
inline |
Append to the end of this Json object's array an element having value of the specified string by moving (in constant time) the contents of string to the new element and return a non-const reference to this object. If isNull(), then the type is changed to array. string is left in a valid but unspecified state. This function does not participate in overload resolution unless the specified t_STRING_TYPE is bsl::string.
string is valid UTF-8 (see bdlde::Utf8Util::isValid). isArray() or isNull().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Return the number of elements in the JsonObject or JsonArray held by this object.
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.
other.
|
inline |
|
inline |
|
inline |
Return a reference providing modifiable access to the value of type boolean held by this object.
isBoolean() returns true.
|
inline |
Return a reference providing non-modifiable access to the value of type boolean held by this object.
isBoolean() returns true.
|
inline |
|
inline |
|
inline |
Return a reference providing modifiable access to the value of type JsonNumber held by this object.
isNumber() returns true.
|
inline |
Return a reference providing non-modifiable access to the value of type JsonNumber held by this object.
isNumber() returns true.
|
inline |
Return a reference providing modifiable access to the value of type JsonObject held by this object.
isObject() returns true.
|
inline |
Return a reference providing non-modifiable access to the value of type JsonObject held by this object.
isObject() returns true.
|
inline |
Return a reference providing non-modifiable access to the value of type JsonString held by this object.
isString() returns true.
|
inline |
Return the type of this Json value.
| RETURN_TYPE bdljsn::Json::visit | ( | BSLS_COMPILERFEATURES_FORWARD_REF(VISITOR) | visitor | ) |
Return the result (having RETURN_TYPE) of invoking the specified visitor (callable) object on this Json object. visitor must be callable as if it provides the following overloads of operator():
The overload corresponding to the current type() of this Json object is invoked. For C++03 visitor must be const qualified.
string overload leaves this Json object with a string that is not valid UTF-8. visitor is const qualified then each of its operator() overloads must also be const qualified. | RETURN_TYPE bdljsn::Json::visit | ( | BSLS_COMPILERFEATURES_FORWARD_REF(VISITOR) | visitor | ) | const |
Return the result (having RETURN_TYPE) of invoking the specified visitor (callable) object on this Json object. visitor must be callable as if it provides the following overloads of operator():
The overload corresponding to the current type() of this Json object is invoked. For C++03 visitor must be const-qualified.
visitor is const qualified then each of its operator() overloads must also be const qualified. 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.
Exchange 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.
a was created with the same allocator as b.