Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
QJsonObject Class Reference

\inmodule QtCore\reentrant More...

#include <qjsonobject.h>

+ Collaboration diagram for QJsonObject:

Classes

class  const_iterator
 \inmodule QtCore More...
 
class  iterator
 \inmodule QtCore\reentrant More...
 

Public Types

typedef iterator Iterator
 Qt-style synonym for QJsonObject::iterator.
 
typedef const_iterator ConstIterator
 Qt-style synonym for QJsonObject::const_iterator.
 
typedef QJsonValue mapped_type
 Typedef for QJsonValue.
 
typedef QString key_type
 Typedef for QString.
 
typedef qsizetype size_type
 Typedef for qsizetype.
 

Public Member Functions

 QJsonObject ()
 Constructs an empty JSON object.
 
 QJsonObject (std::initializer_list< QPair< QString, QJsonValue > > args)
 
 ~QJsonObject ()
 Destroys the object.
 
 QJsonObject (const QJsonObject &other) noexcept
 Creates a copy of other.
 
QJsonObjectoperator= (const QJsonObject &other) noexcept
 Assigns other to this object.
 
 QJsonObject (QJsonObject &&other) noexcept
 
QJsonObjectoperator= (QJsonObject &&other) noexcept
 
void swap (QJsonObject &other) noexcept
 
QVariantMap toVariantMap () const
 Converts this object to a QVariantMap.
 
QVariantHash toVariantHash () const
 Converts this object to a QVariantHash.
 
QStringList keys () const
 Returns a list of all keys in this object.
 
qsizetype size () const
 Returns the number of (key, value) pairs stored in the object.
 
qsizetype count () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Same as size().
 
qsizetype length () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Same as size().
 
bool isEmpty () const
 Returns true if the object is empty.
 
QJsonValue value (const QString &key) const
 Returns a QJsonValue representing the value for the key key.
 
QJsonValue operator[] (const QString &key) const
 Returns a QJsonValue representing the value for the key key.
 
QJsonValueRef operator[] (const QString &key)
 Returns a reference to the value for key.
 
QJsonValue value (QStringView key) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QJsonValue value (QLatin1StringView key) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QJsonValue operator[] (QStringView key) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QJsonValue operator[] (QLatin1StringView key) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QJsonValueRef operator[] (QStringView key)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QJsonValueRef operator[] (QLatin1StringView key)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void remove (const QString &key)
 Removes key from the object.
 
QJsonValue take (const QString &key)
 Removes key from the object.
 
bool contains (const QString &key) const
 Returns true if the object contains key key.
 
void remove (QStringView key)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void remove (QLatin1StringView key)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QJsonValue take (QStringView key)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QJsonValue take (QLatin1StringView key)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool contains (QStringView key) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool contains (QLatin1StringView key) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool operator== (const QJsonObject &other) const
 Returns true if other is equal to this object.
 
bool operator!= (const QJsonObject &other) const
 Returns true if other is not equal to this object.
 
iterator begin ()
 Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in the object.
 
const_iterator begin () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const_iterator constBegin () const
 Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the object.
 
iterator end ()
 Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last item in the object.
 
const_iterator end () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const_iterator constEnd () const
 Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last item in the object.
 
iterator erase (iterator it)
 Removes the (key, value) pair pointed to by the iterator it from the map, and returns an iterator to the next item in the map.
 
iterator find (const QString &key)
 Returns an iterator pointing to the item with key key in the map.
 
const_iterator find (const QString &key) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const_iterator constFind (const QString &key) const
 Returns a const iterator pointing to the item with key key in the map.
 
iterator insert (const QString &key, const QJsonValue &value)
 Inserts a new item with the key key and a value of value.
 
iterator find (QStringView key)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
iterator find (QLatin1StringView key)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const_iterator find (QStringView key) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const_iterator find (QLatin1StringView key) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const_iterator constFind (QStringView key) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const_iterator constFind (QLatin1StringView key) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
iterator insert (QStringView key, const QJsonValue &value)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
iterator insert (QLatin1StringView key, const QJsonValue &value)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool empty () const
 This function is provided for STL compatibility.
 

Static Public Member Functions

static QJsonObject fromVariantMap (const QVariantMap &map)
 Converts the variant map map to a QJsonObject.
 
static QJsonObject fromVariantHash (const QVariantHash &map)
 Converts the variant hash hash to a QJsonObject.
 

Friends

class iterator
 
class const_iterator
 
class QJsonValue
 
class QJsonDocument
 
class QJsonPrivate::Value
 
class QJsonValueConstRef
 
class QJsonValueRef
 
class QCborMap
 
Q_CORE_EXPORT QDebug operator<< (QDebug, const QJsonObject &)
 

Detailed Description

\inmodule QtCore

\reentrant

Since
5.0

The QJsonObject class encapsulates a JSON object.

A JSON object is a list of key value pairs, where the keys are unique strings and the values are represented by a QJsonValue.

A QJsonObject can be converted to and from a QVariantMap. You can query the number of (key, value) pairs with size(), insert(), and remove() entries from it and iterate over its content using the standard C++ iterator pattern.

QJsonObject is an implicitly shared class, and shares the data with the document it has been created from as long as it is not being modified.

You can convert the object to and from text based JSON through QJsonDocument.

See also
{JSON Support in Qt}, {JSON Save Game Example}

Definition at line 19 of file qjsonobject.h.

Member Typedef Documentation

◆ ConstIterator

Qt-style synonym for QJsonObject::const_iterator.

Definition at line 217 of file qjsonobject.h.

◆ Iterator

Qt-style synonym for QJsonObject::iterator.

Definition at line 216 of file qjsonobject.h.

◆ key_type

Typedef for QString.

Provided for STL compatibility.

Definition at line 233 of file qjsonobject.h.

◆ mapped_type

Typedef for QJsonValue.

Provided for STL compatibility.

Definition at line 232 of file qjsonobject.h.

◆ size_type

Typedef for qsizetype.

Provided for STL compatibility.

Definition at line 234 of file qjsonobject.h.

Constructor & Destructor Documentation

◆ QJsonObject() [1/4]

QJsonObject::QJsonObject ( )
default

Constructs an empty JSON object.

See also
isEmpty()

◆ QJsonObject() [2/4]

QJsonObject::QJsonObject ( std::initializer_list< QPair< QString, QJsonValue > >  args)
Since
5.4 Constructs a QJsonObject instance initialized from args initialization list. For example:
{
{"property1", 1},
{"property2", 2}
};
\inmodule QtCore\reentrant
Definition qjsonobject.h:20

Definition at line 114 of file qjsonobject.cpp.

References arg, args, and insert().

+ Here is the call graph for this function:

◆ ~QJsonObject()

QJsonObject::~QJsonObject ( )
default

Destroys the object.

◆ QJsonObject() [3/4]

QJsonObject::QJsonObject ( const QJsonObject other)
defaultnoexcept

Creates a copy of other.

Since QJsonObject is implicitly shared, the copy is shallow as long as the object does not get modified.

◆ QJsonObject() [4/4]

QJsonObject::QJsonObject ( QJsonObject &&  other)
noexcept
Since
5.10

Move-constructs a QJsonObject from other.

Definition at line 133 of file qjsonobject.cpp.

References other().

+ Here is the call graph for this function:

Member Function Documentation

◆ begin() [1/2]

QJsonObject::iterator QJsonObject::begin ( )
inline

Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in the object.

See also
constBegin(), end()

Definition at line 207 of file qjsonobject.h.

◆ begin() [2/2]

QJsonObject::const_iterator QJsonObject::begin ( ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 208 of file qjsonobject.h.

◆ constBegin()

QJsonObject::const_iterator QJsonObject::constBegin ( ) const
inline

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the object.

See also
begin(), constEnd()

Definition at line 209 of file qjsonobject.h.

Referenced by QSSGQmlUtilities::addResource(), QGeoTiledMappingManagerEngineNokia::loadCopyrightsDescriptorsFromJson(), QSSGQmlUtilities::nodeFromJson(), and readInputFile().

+ Here is the caller graph for this function:

◆ constEnd()

QJsonObject::const_iterator QJsonObject::constEnd ( ) const
inline

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last item in the object.

See also
constBegin(), end()

Definition at line 212 of file qjsonobject.h.

Referenced by QSSGQmlUtilities::addResource(), checkBooleanOption(), QT_BEGIN_NAMESPACE::checkDocument(), QT_BEGIN_NAMESPACE::checkLocation(), getRealOption(), QGeoTiledMappingManagerEngineNokia::loadCopyrightsDescriptorsFromJson(), QSSGQmlUtilities::nodeFromJson(), processOptions(), processSceneOptions(), and readInputFile().

+ Here is the caller graph for this function:

◆ constFind() [1/3]

QJsonObject::const_iterator QJsonObject::constFind ( const QString key) const

Returns a const iterator pointing to the item with key key in the map.

If the map contains no item with key key, the function returns constEnd().

Definition at line 730 of file qjsonobject.cpp.

References constFind().

Referenced by checkBooleanOption(), QT_BEGIN_NAMESPACE::checkDocument(), QT_BEGIN_NAMESPACE::checkLocation(), constFind(), getRealOption(), processOptions(), and processSceneOptions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ constFind() [2/3]

QJsonObject::const_iterator QJsonObject::constFind ( QLatin1StringView  key) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.7

Definition at line 748 of file qjsonobject.cpp.

◆ constFind() [3/3]

QJsonObject::const_iterator QJsonObject::constFind ( QStringView  key) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.14

Definition at line 739 of file qjsonobject.cpp.

◆ contains() [1/3]

bool QJsonObject::contains ( const QString key) const

Returns true if the object contains key key.

See also
insert(), remove(), take()

Definition at line 577 of file qjsonobject.cpp.

References contains().

Referenced by GeoRouteJsonParserEsri::GeoRouteJsonParserEsri(), QSSGQmlUtilities::addResource(), contains(), QGtk3Json::load(), CategoryParser::parse(), parseAddressObject(), and parseReview().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ contains() [2/3]

bool QJsonObject::contains ( QLatin1StringView  key) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.7

Definition at line 595 of file qjsonobject.cpp.

◆ contains() [3/3]

bool QJsonObject::contains ( QStringView  key) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.14

Definition at line 586 of file qjsonobject.cpp.

◆ count()

qsizetype QJsonObject::count ( ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Same as size().

Definition at line 51 of file qjsonobject.h.

◆ empty()

bool QJsonObject::empty ( ) const
inline

This function is provided for STL compatibility.

It is equivalent to isEmpty(), returning true if the object is empty; otherwise returning false.

Definition at line 236 of file qjsonobject.h.

◆ end() [1/2]

QJsonObject::iterator QJsonObject::end ( )
inline

Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last item in the object.

See also
begin(), constEnd()

Definition at line 210 of file qjsonobject.h.

Referenced by keys(), operator==(), and QGeoRouteParserOsrmV5Private::parseStep().

+ Here is the caller graph for this function:

◆ end() [2/2]

QJsonObject::const_iterator QJsonObject::end ( ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 211 of file qjsonobject.h.

◆ erase()

QJsonObject::iterator QJsonObject::erase ( QJsonObject::iterator  it)

Removes the (key, value) pair pointed to by the iterator it from the map, and returns an iterator to the next item in the map.

See also
remove()

Definition at line 652 of file qjsonobject.cpp.

References it.

◆ find() [1/6]

QJsonObject::iterator QJsonObject::find ( const QString key)

Returns an iterator pointing to the item with key key in the map.

If the map contains no item with key key, the function returns end().

Definition at line 669 of file qjsonobject.cpp.

References find().

Referenced by find(), and QGeoRouteParserOsrmV5Private::parseStep().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ find() [2/6]

QJsonObject::const_iterator QJsonObject::find ( const QString key) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 219 of file qjsonobject.h.

◆ find() [3/6]

QJsonObject::iterator QJsonObject::find ( QLatin1StringView  key)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.7

Definition at line 687 of file qjsonobject.cpp.

◆ find() [4/6]

QJsonObject::const_iterator QJsonObject::find ( QLatin1StringView  key) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.7

Definition at line 225 of file qjsonobject.h.

◆ find() [5/6]

QJsonObject::iterator QJsonObject::find ( QStringView  key)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.14

Definition at line 678 of file qjsonobject.cpp.

◆ find() [6/6]

QJsonObject::const_iterator QJsonObject::find ( QStringView  key) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.14

Definition at line 224 of file qjsonobject.h.

◆ fromVariantHash()

QJsonObject QJsonObject::fromVariantHash ( const QVariantHash hash)
static

Converts the variant hash hash to a QJsonObject.

Since
5.5

The keys in hash will be used as the keys in the JSON object, and the QVariant values will be converted to JSON values.

Note
Conversion from \l QVariant is not completely lossless. Please see the documentation in QJsonValue::fromVariant() for more information.
See also
fromVariantMap(), toVariantHash(), QJsonValue::fromVariant()

Definition at line 200 of file qjsonobject.cpp.

References QHash< QString, QVariant >::const_iterator, QJsonValue::fromVariant(), hash, insert(), and it.

Referenced by QJsonDocument::fromVariant(), and QJsonValue::fromVariant().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromVariantMap()

QJsonObject QJsonObject::fromVariantMap ( const QVariantMap map)
static

Converts the variant map map to a QJsonObject.

The keys in map will be used as the keys in the JSON object, and the QVariant values will be converted to JSON values.

Note
Conversion from \l QVariant is not completely lossless. Please see the documentation in QJsonValue::fromVariant() for more information.
See also
fromVariantHash(), toVariantMap(), QJsonValue::fromVariant()

Definition at line 171 of file qjsonobject.cpp.

References map, and QJsonPrivate::Variant::toJsonObject().

Referenced by QJsonDocument::fromVariant(), and QJsonValue::fromVariant().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert() [1/3]

QJsonObject::iterator QJsonObject::insert ( const QString key,
const QJsonValue value 
)

Inserts a new item with the key key and a value of value.

If there is already an item with the key key, then that item's value is replaced with value.

Returns an iterator pointing to the inserted item.

If the value is QJsonValue::Undefined, it will cause the key to get removed from the object. The returned iterator will then point to end().

See also
remove(), take(), QJsonObject::iterator, end()

Definition at line 417 of file qjsonobject.cpp.

References insert().

Referenced by QJsonObject(), V4CommandHandler::addBody(), V4CommandHandler::addCommand(), V4CommandHandler::addRequestSequence(), V4CommandHandler::addRunning(), V4CommandHandler::addSuccess(), Collector::collect(), collectProperty(), V4CommandHandler::createErrorResponse(), QV4DebuggerAgent::debuggerPaused(), exportFeature(), exportFeatureCollection(), exportGeometryCollection(), exportLineString(), exportMultiLineString(), exportMultiPoint(), exportMultiPolygon(), exportPoint(), exportPolygon(), fromVariantHash(), BreakPointHandler::handleRemoveBreakpoint(), BreakPointHandler::handleSetBreakpoint(), insert(), QV4DataCollector::lookupRef(), QQmlNativeDebugServiceImpl::messageReceived(), QGtk3Json::save(), setError(), QmlLsp::QQmlLanguageServer::setupCapabilities(), and toRef().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert() [2/3]

QJsonObject::iterator QJsonObject::insert ( QLatin1StringView  key,
const QJsonValue value 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.14

Definition at line 435 of file qjsonobject.cpp.

◆ insert() [3/3]

QJsonObject::iterator QJsonObject::insert ( QStringView  key,
const QJsonValue value 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.14

Definition at line 426 of file qjsonobject.cpp.

◆ isEmpty()

bool QJsonObject::isEmpty ( ) const

Returns true if the object is empty.

This is the same as size() == 0.

See also
size()

Definition at line 252 of file qjsonobject.cpp.

References QCborContainerPrivate::elements, and QList< T >::isEmpty().

Referenced by QV4DebuggerAgent::debuggerPaused(), V4CommandHandler::handle(), importImp(), QGtk3Json::load(), processOptions(), processSceneOptions(), and readInputFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ keys()

QStringList QJsonObject::keys ( ) const

Returns a list of all keys in this object.

The list is sorted lexographically.

Definition at line 228 of file qjsonobject.cpp.

References QCborContainerPrivate::elements, end(), i, keys(), QList< T >::size(), and QCborContainerPrivate::stringAt().

Referenced by keys(), QGtk3Json::load(), and QGtk3Json::save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ length()

qsizetype QJsonObject::length ( ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Same as size().

Definition at line 52 of file qjsonobject.h.

◆ operator!=()

bool QJsonObject::operator!= ( const QJsonObject other) const

Returns true if other is not equal to this object.

Definition at line 640 of file qjsonobject.cpp.

References other().

+ Here is the call graph for this function:

◆ operator=() [1/2]

QJsonObject & QJsonObject::operator= ( const QJsonObject other)
defaultnoexcept

Assigns other to this object.

◆ operator=() [2/2]

QJsonObject & QJsonObject::operator= ( QJsonObject &&  other)
inlinenoexcept
Since
5.10

Move-assigns other to this object.

Definition at line 33 of file qjsonobject.h.

References other(), and swap().

+ Here is the call graph for this function:

◆ operator==()

bool QJsonObject::operator== ( const QJsonObject other) const

Returns true if other is equal to this object.

Definition at line 617 of file qjsonobject.cpp.

References QCborContainerPrivate::elements, end(), i, other(), QList< T >::size(), and QCborContainerPrivate::valueAt().

+ Here is the call graph for this function:

◆ operator[]() [1/6]

QJsonValueRef QJsonObject::operator[] ( const QString key)

Returns a reference to the value for key.

If there is no value with key key in the object, one is created with a QJsonValue::Null value and then returned.

The return value is of type QJsonValueRef, a helper class for QJsonArray and QJsonObject. When you get an object of type QJsonValueRef, you can use it as if it were a reference to a QJsonValue. If you assign to it, the assignment will apply to the element in the QJsonArray or QJsonObject from which you got the reference.

See also
value()

Definition at line 361 of file qjsonobject.cpp.

◆ operator[]() [2/6]

QJsonValue QJsonObject::operator[] ( const QString key) const

Returns a QJsonValue representing the value for the key key.

This does the same as value().

The returned QJsonValue is QJsonValue::Undefined if the key does not exist.

See also
value(), QJsonValue, QJsonValue::isUndefined()

Definition at line 329 of file qjsonobject.cpp.

◆ operator[]() [3/6]

QJsonValueRef QJsonObject::operator[] ( QLatin1StringView  key)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.7

Definition at line 379 of file qjsonobject.cpp.

◆ operator[]() [4/6]

QJsonValue QJsonObject::operator[] ( QLatin1StringView  key) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.7

Definition at line 61 of file qjsonobject.h.

◆ operator[]() [5/6]

QJsonValueRef QJsonObject::operator[] ( QStringView  key)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.14

Definition at line 370 of file qjsonobject.cpp.

◆ operator[]() [6/6]

QJsonValue QJsonObject::operator[] ( QStringView  key) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.14

Definition at line 60 of file qjsonobject.h.

◆ remove() [1/3]

void QJsonObject::remove ( const QString key)

Removes key from the object.

See also
insert(), take()

Definition at line 480 of file qjsonobject.cpp.

References remove().

Referenced by remove().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remove() [2/3]

void QJsonObject::remove ( QLatin1StringView  key)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.14

Definition at line 498 of file qjsonobject.cpp.

◆ remove() [3/3]

void QJsonObject::remove ( QStringView  key)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.14

Definition at line 489 of file qjsonobject.cpp.

◆ size()

qsizetype QJsonObject::size ( ) const

Returns the number of (key, value) pairs stored in the object.

Definition at line 242 of file qjsonobject.cpp.

References QCborContainerPrivate::elements, and QList< T >::size().

Referenced by QShaderDescriptionPrivate::makeDoc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ swap()

void QJsonObject::swap ( QJsonObject other)
inlinenoexcept
Since
5.10

Swaps the object other with this. This operation is very fast and never fails.

Definition at line 39 of file qjsonobject.h.

References o, and other().

+ Here is the call graph for this function:

◆ take() [1/3]

QJsonValue QJsonObject::take ( const QString key)

Removes key from the object.

Returns a QJsonValue containing the value referenced by key. If key was not contained in the object, the returned QJsonValue is QJsonValue::Undefined.

See also
insert(), remove(), QJsonValue

Definition at line 529 of file qjsonobject.cpp.

References take().

Referenced by take().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ take() [2/3]

QJsonValue QJsonObject::take ( QLatin1StringView  key)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.14

Definition at line 547 of file qjsonobject.cpp.

◆ take() [3/3]

QJsonValue QJsonObject::take ( QStringView  key)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.14

Definition at line 538 of file qjsonobject.cpp.

◆ toVariantHash()

QVariantHash QJsonObject::toVariantHash ( ) const

Converts this object to a QVariantHash.

Since
5.5

Returns the created hash.

See also
toVariantMap()

Definition at line 218 of file qjsonobject.cpp.

References QCborMap::fromJsonObject(), and QCborMap::toVariantHash().

+ Here is the call graph for this function:

◆ toVariantMap()

QVariantMap QJsonObject::toVariantMap ( ) const

Converts this object to a QVariantMap.

Returns the created map.

See also
toVariantHash()

Definition at line 183 of file qjsonobject.cpp.

References QCborMap::fromJsonObject(), and QCborMap::toVariantMap().

Referenced by QDefaultOutputMapping::load(), loadAndroidStyle(), QKmsScreenConfig::loadConfig(), QJsonDocument::toVariant(), and QJsonValue::toVariant().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ value() [1/3]

QJsonValue QJsonObject::value ( const QString key) const

Returns a QJsonValue representing the value for the key key.

The returned QJsonValue is QJsonValue::Undefined if the key does not exist.

See also
QJsonValue, QJsonValue::isUndefined()

Definition at line 281 of file qjsonobject.cpp.

Referenced by GeoRouteJsonParserEsri::GeoRouteJsonParserEsri(), QSSGQmlUtilities::addResource(), QSSGQmlUtilities::applyEdit(), constructRoute(), V4CommandHandler::createErrorResponse(), V4CommandHandler::handle(), UnknownV4CommandHandler::handleRequest(), instructionDepart(), instructionDirection(), instructionRotary(), instructionRoundabout(), instructionText(), instructionUseLane(), QDefaultOutputMapping::load(), TileProvider::onNetworkReplyFinished(), QJsonValue::operator[](), QJsonValue::operator[](), CategoryParser::parse(), parseAddressObject(), parseCategory(), parseContactDetails(), QT_BEGIN_NAMESPACE::parseDocument(), parseEditorial(), QMapboxCommon::parseGeoLocation(), parseImage(), QT_BEGIN_NAMESPACE::parseLocation(), parseMapboxBanner(), parseMapboxBannerComponent(), parseMapboxBannerInstruction(), parseMapboxVoiceInstruction(), QT_BEGIN_NAMESPACE::parsePlaceResult(), QGeoRouteParserOsrmV5Private::parseReply(), QGeoRouteParserOsrmV4Private::parseReply(), parseReview(), QGeoRouteParserOsrmV5Private::parseStep(), parseSupplier(), readGpuFeatures(), readInputFile(), readInputFileDirectory(), QV4DebugClient::response(), and QGeoRouteParserOsrmV5ExtensionMapbox::updateSegment().

+ Here is the caller graph for this function:

◆ value() [2/3]

QJsonValue QJsonObject::value ( QLatin1StringView  key) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.7

Definition at line 299 of file qjsonobject.cpp.

◆ value() [3/3]

QJsonValue QJsonObject::value ( QStringView  key) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
5.14

Definition at line 290 of file qjsonobject.cpp.

Friends And Related Symbol Documentation

◆ const_iterator

friend class const_iterator
friend

Definition at line 204 of file qjsonobject.h.

◆ iterator

friend class iterator
friend

Definition at line 141 of file qjsonobject.h.

◆ operator<<

Q_CORE_EXPORT QDebug operator<< ( QDebug  ,
const QJsonObject  
)
friend

Definition at line 1418 of file qjsonobject.cpp.

◆ QCborMap

friend class QCborMap
friend

Definition at line 244 of file qjsonobject.h.

◆ QJsonDocument

friend class QJsonDocument
friend

Definition at line 240 of file qjsonobject.h.

◆ QJsonPrivate::Value

friend class QJsonPrivate::Value
friend

Definition at line 241 of file qjsonobject.h.

◆ QJsonValue

friend class QJsonValue
friend

Definition at line 239 of file qjsonobject.h.

Referenced by operator==(), operator==(), and operator==().

◆ QJsonValueConstRef

friend class QJsonValueConstRef
friend

Definition at line 242 of file qjsonobject.h.

◆ QJsonValueRef

friend class QJsonValueRef
friend

Definition at line 243 of file qjsonobject.h.


The documentation for this class was generated from the following files: