Struct qt_core::QJsonObject

source ·
#[repr(C)]
pub struct QJsonObject { /* private fields */ }
Expand description

The QJsonObject class encapsulates a JSON object.

C++ class: QJsonObject.

C++ documentation:

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.

Implementations§

source§

impl QJsonObject

source

pub unsafe fn begin_mut(&self) -> CppBox<Iterator>

Returns an STL-style iterator pointing to the first item in the object.

Calls C++ function: QJsonObject::iterator QJsonObject::begin().

C++ documentation:

Returns an STL-style iterator pointing to the first item in the object.

See also constBegin() and end().

source

pub unsafe fn begin(&self) -> CppBox<ConstIterator>

This is an overloaded function.

Calls C++ function: QJsonObject::const_iterator QJsonObject::begin() const.

C++ documentation:

This is an overloaded function.

source

pub unsafe fn const_begin(&self) -> CppBox<ConstIterator>

Returns a const STL-style iterator pointing to the first item in the object.

Calls C++ function: QJsonObject::const_iterator QJsonObject::constBegin() const.

C++ documentation:

Returns a const STL-style iterator pointing to the first item in the object.

See also begin() and constEnd().

source

pub unsafe fn const_end(&self) -> CppBox<ConstIterator>

Returns a const STL-style iterator pointing to the imaginary item after the last item in the object.

Calls C++ function: QJsonObject::const_iterator QJsonObject::constEnd() const.

C++ documentation:

Returns a const STL-style iterator pointing to the imaginary item after the last item in the object.

See also constBegin() and end().

source

pub unsafe fn const_find_q_string( &self, key: impl CastInto<Ref<QString>> ) -> CppBox<ConstIterator>

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

Calls C++ function: QJsonObject::const_iterator QJsonObject::constFind(const QString& key) const.

C++ documentation:

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().

source

pub unsafe fn const_find_q_latin1_string( &self, key: impl CastInto<Ref<QLatin1String>> ) -> CppBox<ConstIterator>

This is an overloaded function.

Calls C++ function: QJsonObject::const_iterator QJsonObject::constFind(QLatin1String key) const.

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.7.

source

pub unsafe fn const_find_q_string_view( &self, key: impl CastInto<Ref<QStringView>> ) -> CppBox<ConstIterator>

Available on cpp_lib_version="5.14.0" only.

This is an overloaded function.

Calls C++ function: QJsonObject::const_iterator QJsonObject::constFind(QStringView key) const.

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.14.

source

pub unsafe fn contains_q_string(&self, key: impl CastInto<Ref<QString>>) -> bool

Returns true if the object contains key key.

Calls C++ function: bool QJsonObject::contains(const QString& key) const.

C++ documentation:

Returns true if the object contains key key.

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

source

pub unsafe fn contains_q_latin1_string( &self, key: impl CastInto<Ref<QLatin1String>> ) -> bool

This is an overloaded function.

Calls C++ function: bool QJsonObject::contains(QLatin1String key) const.

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.7.

source

pub unsafe fn contains_q_string_view( &self, key: impl CastInto<Ref<QStringView>> ) -> bool

Available on cpp_lib_version="5.14.0" only.

This is an overloaded function.

Calls C++ function: bool QJsonObject::contains(QStringView key) const.

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.14.

source

pub unsafe fn copy_from( &self, other: impl CastInto<Ref<QJsonObject>> ) -> Ref<QJsonObject>

Assigns other to this object.

Calls C++ function: QJsonObject& QJsonObject::operator=(const QJsonObject& other).

C++ documentation:

Assigns other to this object.

source

pub unsafe fn count(&self) -> c_int

This is an overloaded function.

Calls C++ function: int QJsonObject::count() const.

C++ documentation:

This is an overloaded function.

Same as size().

source

pub unsafe fn empty(&self) -> bool

This function is provided for STL compatibility. It is equivalent to isEmpty(), returning true if the object is empty; otherwise returning false.

Calls C++ function: bool QJsonObject::empty() const.

C++ documentation:

This function is provided for STL compatibility. It is equivalent to isEmpty(), returning true if the object is empty; otherwise returning false.

source

pub unsafe fn end_mut(&self) -> CppBox<Iterator>

Returns an STL-style iterator pointing to the imaginary item after the last item in the object.

Calls C++ function: QJsonObject::iterator QJsonObject::end().

C++ documentation:

Returns an STL-style iterator pointing to the imaginary item after the last item in the object.

See also begin() and constEnd().

source

pub unsafe fn end(&self) -> CppBox<ConstIterator>

This is an overloaded function.

Calls C++ function: QJsonObject::const_iterator QJsonObject::end() const.

C++ documentation:

This is an overloaded function.

source

pub unsafe fn erase(&self, it: impl CastInto<Ref<Iterator>>) -> CppBox<Iterator>

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.

Calls C++ function: QJsonObject::iterator QJsonObject::erase(QJsonObject::iterator it).

C++ documentation:

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().

source

pub unsafe fn find_q_string_mut( &self, key: impl CastInto<Ref<QString>> ) -> CppBox<Iterator>

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

Calls C++ function: QJsonObject::iterator QJsonObject::find(const QString& key).

C++ documentation:

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().

source

pub unsafe fn find_q_latin1_string_mut( &self, key: impl CastInto<Ref<QLatin1String>> ) -> CppBox<Iterator>

This is an overloaded function.

Calls C++ function: QJsonObject::iterator QJsonObject::find(QLatin1String key).

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.7.

source

pub unsafe fn find_q_string( &self, key: impl CastInto<Ref<QString>> ) -> CppBox<ConstIterator>

This is an overloaded function.

Calls C++ function: QJsonObject::const_iterator QJsonObject::find(const QString& key) const.

C++ documentation:

This is an overloaded function.

source

pub unsafe fn find_q_latin1_string( &self, key: impl CastInto<Ref<QLatin1String>> ) -> CppBox<ConstIterator>

This is an overloaded function.

Calls C++ function: QJsonObject::const_iterator QJsonObject::find(QLatin1String key) const.

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.7.

source

pub unsafe fn find_q_string_view_mut( &self, key: impl CastInto<Ref<QStringView>> ) -> CppBox<Iterator>

Available on cpp_lib_version="5.14.0" only.

This is an overloaded function.

Calls C++ function: QJsonObject::iterator QJsonObject::find(QStringView key).

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.14.

source

pub unsafe fn find_q_string_view( &self, key: impl CastInto<Ref<QStringView>> ) -> CppBox<ConstIterator>

Available on cpp_lib_version="5.14.0" only.

This is an overloaded function.

Calls C++ function: QJsonObject::const_iterator QJsonObject::find(QStringView key) const.

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.14.

source

pub unsafe fn from_variant_hash( map: impl CastInto<Ref<QHashOfQStringQVariant>> ) -> CppBox<QJsonObject>

Converts the variant hash hash to a QJsonObject.

Calls C++ function: static QJsonObject QJsonObject::fromVariantHash(const QHash<QString, QVariant>& map).

C++ documentation:

Converts the variant hash hash to a QJsonObject.

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

This function was introduced in Qt 5.5.

See also fromVariantMap(), toVariantHash(), and QJsonValue::fromVariant().

source

pub unsafe fn from_variant_map( map: impl CastInto<Ref<QMapOfQStringQVariant>> ) -> CppBox<QJsonObject>

Converts the variant map map to a QJsonObject.

Calls C++ function: static QJsonObject QJsonObject::fromVariantMap(const QMap<QString, QVariant>& map).

C++ documentation:

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.

See also fromVariantHash(), toVariantMap(), and QJsonValue::fromVariant().

source

pub unsafe fn index_q_string( &self, key: impl CastInto<Ref<QString>> ) -> CppBox<QJsonValue>

Returns a QJsonValue representing the value for the key key.

Calls C++ function: QJsonValue QJsonObject::operator[](const QString& key) const.

C++ documentation:

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, and QJsonValue::isUndefined().

source

pub unsafe fn index_q_latin1_string( &self, key: impl CastInto<Ref<QLatin1String>> ) -> CppBox<QJsonValue>

This is an overloaded function.

Calls C++ function: QJsonValue QJsonObject::operator[](QLatin1String key) const.

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.7.

source

pub unsafe fn index_q_string_mut( &self, key: impl CastInto<Ref<QString>> ) -> CppBox<QJsonValueRef>

Returns a reference to the value for key.

Calls C++ function: QJsonValueRef QJsonObject::operator[](const QString& key).

C++ documentation:

Returns a reference to the value for key.

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().

source

pub unsafe fn index_q_latin1_string_mut( &self, key: impl CastInto<Ref<QLatin1String>> ) -> CppBox<QJsonValueRef>

This is an overloaded function.

Calls C++ function: QJsonValueRef QJsonObject::operator[](QLatin1String key).

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.7.

source

pub unsafe fn index_q_string_view( &self, key: impl CastInto<Ref<QStringView>> ) -> CppBox<QJsonValue>

Available on cpp_lib_version="5.14.0" only.

This is an overloaded function.

Calls C++ function: QJsonValue QJsonObject::operator[](QStringView key) const.

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.14.

source

pub unsafe fn index_q_string_view_mut( &self, key: impl CastInto<Ref<QStringView>> ) -> CppBox<QJsonValueRef>

Available on cpp_lib_version="5.14.0" only.

This is an overloaded function.

Calls C++ function: QJsonValueRef QJsonObject::operator[](QStringView key).

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.14.

source

pub unsafe fn insert_q_string_q_json_value( &self, key: impl CastInto<Ref<QString>>, value: impl CastInto<Ref<QJsonValue>> ) -> CppBox<Iterator>

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

Calls C++ function: QJsonObject::iterator QJsonObject::insert(const QString& key, const QJsonValue& value).

C++ documentation:

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, and end().

source

pub unsafe fn insert_q_string_view_q_json_value( &self, key: impl CastInto<Ref<QStringView>>, value: impl CastInto<Ref<QJsonValue>> ) -> CppBox<Iterator>

Available on cpp_lib_version="5.14.0" only.

This is an overloaded function.

Calls C++ function: QJsonObject::iterator QJsonObject::insert(QStringView key, const QJsonValue& value).

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.14.

source

pub unsafe fn insert_q_latin1_string_q_json_value( &self, key: impl CastInto<Ref<QLatin1String>>, value: impl CastInto<Ref<QJsonValue>> ) -> CppBox<Iterator>

This is an overloaded function.

Calls C++ function: QJsonObject::iterator QJsonObject::insert(QLatin1String key, const QJsonValue& value).

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.14.

source

pub unsafe fn is_empty(&self) -> bool

Returns true if the object is empty. This is the same as size() == 0.

Calls C++ function: bool QJsonObject::isEmpty() const.

C++ documentation:

Returns true if the object is empty. This is the same as size() == 0.

See also size().

source

pub unsafe fn keys(&self) -> CppBox<QStringList>

Returns a list of all keys in this object.

Calls C++ function: QStringList QJsonObject::keys() const.

C++ documentation:

Returns a list of all keys in this object.

The list is sorted lexographically.

source

pub unsafe fn length(&self) -> c_int

This is an overloaded function.

Calls C++ function: int QJsonObject::length() const.

C++ documentation:

This is an overloaded function.

Same as size().

source

pub unsafe fn new() -> CppBox<QJsonObject>

Constructs an empty JSON object.

Calls C++ function: [constructor] void QJsonObject::QJsonObject().

C++ documentation:

Constructs an empty JSON object.

See also isEmpty().

source

pub unsafe fn new_copy( other: impl CastInto<Ref<QJsonObject>> ) -> CppBox<QJsonObject>

Creates a copy of other.

Calls C++ function: [constructor] void QJsonObject::QJsonObject(const QJsonObject& other).

C++ documentation:

Creates a copy of other.

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

source

pub unsafe fn remove_q_string(&self, key: impl CastInto<Ref<QString>>)

Removes key from the object.

Calls C++ function: void QJsonObject::remove(const QString& key).

C++ documentation:

Removes key from the object.

See also insert() and take().

source

pub unsafe fn remove_q_string_view(&self, key: impl CastInto<Ref<QStringView>>)

Available on cpp_lib_version="5.14.0" only.

This is an overloaded function.

Calls C++ function: void QJsonObject::remove(QStringView key).

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.14.

source

pub unsafe fn remove_q_latin1_string( &self, key: impl CastInto<Ref<QLatin1String>> )

This is an overloaded function.

Calls C++ function: void QJsonObject::remove(QLatin1String key).

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.14.

source

pub unsafe fn size(&self) -> c_int

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

Calls C++ function: int QJsonObject::size() const.

C++ documentation:

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

source

pub unsafe fn swap(&self, other: impl CastInto<Ref<QJsonObject>>)

Available on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

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

Calls C++ function: void QJsonObject::swap(QJsonObject& other).

C++ documentation:

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

This function was introduced in Qt 5.10.

source

pub unsafe fn take_q_string( &self, key: impl CastInto<Ref<QString>> ) -> CppBox<QJsonValue>

Removes key from the object.

Calls C++ function: QJsonValue QJsonObject::take(const QString& key).

C++ documentation:

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(), and QJsonValue.

source

pub unsafe fn take_q_string_view( &self, key: impl CastInto<Ref<QStringView>> ) -> CppBox<QJsonValue>

Available on cpp_lib_version="5.14.0" only.

This is an overloaded function.

Calls C++ function: QJsonValue QJsonObject::take(QStringView key).

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.14.

source

pub unsafe fn take_q_latin1_string( &self, key: impl CastInto<Ref<QLatin1String>> ) -> CppBox<QJsonValue>

This is an overloaded function.

Calls C++ function: QJsonValue QJsonObject::take(QLatin1String key).

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.14.

source

pub unsafe fn to_variant_hash(&self) -> CppBox<QHashOfQStringQVariant>

Converts this object to a QVariantHash.

Calls C++ function: QHash<QString, QVariant> QJsonObject::toVariantHash() const.

C++ documentation:

Converts this object to a QVariantHash.

Returns the created hash.

This function was introduced in Qt 5.5.

See also toVariantMap().

source

pub unsafe fn to_variant_map(&self) -> CppBox<QMapOfQStringQVariant>

Converts this object to a QVariantMap.

Calls C++ function: QMap<QString, QVariant> QJsonObject::toVariantMap() const.

C++ documentation:

Converts this object to a QVariantMap.

Returns the created map.

See also toVariantHash().

source

pub unsafe fn value_q_string( &self, key: impl CastInto<Ref<QString>> ) -> CppBox<QJsonValue>

Returns a QJsonValue representing the value for the key key.

Calls C++ function: QJsonValue QJsonObject::value(const QString& key) const.

C++ documentation:

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 and QJsonValue::isUndefined().

source

pub unsafe fn value_q_latin1_string( &self, key: impl CastInto<Ref<QLatin1String>> ) -> CppBox<QJsonValue>

This is an overloaded function.

Calls C++ function: QJsonValue QJsonObject::value(QLatin1String key) const.

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.7.

source

pub unsafe fn value_q_string_view( &self, key: impl CastInto<Ref<QStringView>> ) -> CppBox<QJsonValue>

Available on cpp_lib_version="5.14.0" only.

This is an overloaded function.

Calls C++ function: QJsonValue QJsonObject::value(QStringView key) const.

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.14.

Trait Implementations§

source§

impl Begin for QJsonObject

source§

unsafe fn begin(&self) -> CppBox<ConstIterator>

This is an overloaded function.

Calls C++ function: QJsonObject::const_iterator QJsonObject::begin() const.

C++ documentation:

This is an overloaded function.

§

type Output = CppBox<ConstIterator>

Output type.
source§

impl BeginMut for QJsonObject

source§

unsafe fn begin_mut(&self) -> CppBox<Iterator>

Returns an STL-style iterator pointing to the first item in the object.

Calls C++ function: QJsonObject::iterator QJsonObject::begin().

C++ documentation:

Returns an STL-style iterator pointing to the first item in the object.

See also constBegin() and end().

§

type Output = CppBox<Iterator>

Output type.
source§

impl CppDeletable for QJsonObject

source§

unsafe fn delete(&self)

Destroys the object.

Calls C++ function: [destructor] void QJsonObject::~QJsonObject().

C++ documentation:

Destroys the object.

source§

impl End for QJsonObject

source§

unsafe fn end(&self) -> CppBox<ConstIterator>

This is an overloaded function.

Calls C++ function: QJsonObject::const_iterator QJsonObject::end() const.

C++ documentation:

This is an overloaded function.

§

type Output = CppBox<ConstIterator>

Output type.
source§

impl EndMut for QJsonObject

source§

unsafe fn end_mut(&self) -> CppBox<Iterator>

Returns an STL-style iterator pointing to the imaginary item after the last item in the object.

Calls C++ function: QJsonObject::iterator QJsonObject::end().

C++ documentation:

Returns an STL-style iterator pointing to the imaginary item after the last item in the object.

See also begin() and constEnd().

§

type Output = CppBox<Iterator>

Output type.
source§

impl PartialEq<Ref<QJsonObject>> for QJsonObject

source§

fn eq(&self, other: &Ref<QJsonObject>) -> bool

Returns true if other is equal to this object.

Calls C++ function: bool QJsonObject::operator==(const QJsonObject& other) const.

C++ documentation:

Returns true if other is equal to this object.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Size for QJsonObject

source§

unsafe fn size(&self) -> usize

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

Calls C++ function: int QJsonObject::size() const.

C++ documentation:

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

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.