Struct qt_core::QJsonValue

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

The QJsonValue class encapsulates a value in JSON.

C++ class: QJsonValue.

C++ documentation:

The QJsonValue class encapsulates a value in JSON.

A value in JSON can be one of 6 basic types:

JSON is a format to store structured data. It has 6 basic data types:

A value can represent any of the above data types. In addition, QJsonValue has one special flag to represent undefined values. This can be queried with isUndefined().

The type of the value can be queried with type() or accessors like isBool(), isString(), and so on. Likewise, the value can be converted to the type stored in it using the toBool(), toString() and so on.

Values are strictly typed internally and contrary to QVariant will not attempt to do any implicit type conversions. This implies that converting to a type that is not stored in the value will return a default constructed return value.

Implementations§

source§

impl QJsonValue

source

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

Assigns the value stored in other to this object.

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

C++ documentation:

Assigns the value stored in other to this object.

source

pub unsafe fn from_variant( variant: impl CastInto<Ref<QVariant>> ) -> CppBox<QJsonValue>

Converts variant to a QJsonValue and returns it.

Calls C++ function: static QJsonValue QJsonValue::fromVariant(const QVariant& variant).

C++ documentation:

Converts variant to a QJsonValue and returns it.

The conversion will convert QVariant types as follows:

For all other QVariant types a conversion to a QString will be attempted. If the returned string is empty, a Null QJsonValue will be stored, otherwise a String value using the returned QString.

See also toVariant().

source

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

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.

Returns a QJsonValue representing the value for the key key.

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

C++ documentation:

Returns a QJsonValue representing the value for the key key.

Equivalent to calling toObject().value(key).

The returned QJsonValue is QJsonValue::Undefined if the key does not exist, or if isObject() is false.

This function was introduced in Qt 5.10.

See also QJsonValue, QJsonValue::isUndefined(), and QJsonObject.

source

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

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.

This is an overloaded function.

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

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.10.

source

pub unsafe fn index_int(&self, i: c_int) -> CppBox<QJsonValue>

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.

Returns a QJsonValue representing the value for index i.

Calls C++ function: QJsonValue QJsonValue::operator[](int i) const.

C++ documentation:

Returns a QJsonValue representing the value for index i.

Equivalent to calling toArray().at(i).

The returned QJsonValue is QJsonValue::Undefined, if i is out of bounds, or if isArray() is false.

This function was introduced in Qt 5.10.

See also QJsonValue, QJsonValue::isUndefined(), and QJsonArray.

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 QJsonValue::operator[](QStringView key) const.

C++ documentation:

This is an overloaded function.

This function was introduced in Qt 5.14.

source

pub unsafe fn is_array(&self) -> bool

Returns true if the value contains an array.

Calls C++ function: bool QJsonValue::isArray() const.

C++ documentation:

Returns true if the value contains an array.

See also toArray().

source

pub unsafe fn is_bool(&self) -> bool

Returns true if the value contains a boolean.

Calls C++ function: bool QJsonValue::isBool() const.

C++ documentation:

Returns true if the value contains a boolean.

See also toBool().

source

pub unsafe fn is_double(&self) -> bool

Returns true if the value contains a double.

Calls C++ function: bool QJsonValue::isDouble() const.

C++ documentation:

Returns true if the value contains a double.

See also toDouble().

source

pub unsafe fn is_null(&self) -> bool

Returns true if the value is null.

Calls C++ function: bool QJsonValue::isNull() const.

C++ documentation:

Returns true if the value is null.

source

pub unsafe fn is_object(&self) -> bool

Returns true if the value contains an object.

Calls C++ function: bool QJsonValue::isObject() const.

C++ documentation:

Returns true if the value contains an object.

See also toObject().

source

pub unsafe fn is_string(&self) -> bool

Returns true if the value contains a string.

Calls C++ function: bool QJsonValue::isString() const.

C++ documentation:

Returns true if the value contains a string.

See also toString().

source

pub unsafe fn is_undefined(&self) -> bool

Returns true if the value is undefined. This can happen in certain error cases as e.g. accessing a non existing key in a QJsonObject.

Calls C++ function: bool QJsonValue::isUndefined() const.

C++ documentation:

Returns true if the value is undefined. This can happen in certain error cases as e.g. accessing a non existing key in a QJsonObject.

source

pub unsafe fn from_type(arg1: Type) -> CppBox<QJsonValue>

Creates a QJsonValue of type type.

Calls C++ function: [constructor] void QJsonValue::QJsonValue(QJsonValue::Type arg1 = …).

C++ documentation:

Creates a QJsonValue of type type.

The default is to create a Null value.

source

pub unsafe fn from_bool(b: bool) -> CppBox<QJsonValue>

Creates a value of type Bool, with value b.

Calls C++ function: [constructor] void QJsonValue::QJsonValue(bool b).

C++ documentation:

Creates a value of type Bool, with value b.

source

pub unsafe fn from_double(n: c_double) -> CppBox<QJsonValue>

Creates a value of type Double, with value n.

Calls C++ function: [constructor] void QJsonValue::QJsonValue(double n).

C++ documentation:

Creates a value of type Double, with value n.

source

pub unsafe fn from_int(n: c_int) -> CppBox<QJsonValue>

This is an overloaded function.

Calls C++ function: [constructor] void QJsonValue::QJsonValue(int n).

C++ documentation:

This is an overloaded function.

Creates a value of type Double, with value n.

source

pub unsafe fn from_i64(n: i64) -> CppBox<QJsonValue>

This is an overloaded function.

Calls C++ function: [constructor] void QJsonValue::QJsonValue(qint64 n).

C++ documentation:

This is an overloaded function.

Creates a value of type Double, with value n. NOTE: the integer limits for IEEE 754 double precision data is 2^53 (-9007199254740992 to +9007199254740992). If you pass in values outside this range expect a loss of precision to occur.

source

pub unsafe fn from_q_string( s: impl CastInto<Ref<QString>> ) -> CppBox<QJsonValue>

Creates a value of type String, with value s.

Calls C++ function: [constructor] void QJsonValue::QJsonValue(const QString& s).

C++ documentation:

Creates a value of type String, with value s.

source

pub unsafe fn from_q_latin1_string( s: impl CastInto<Ref<QLatin1String>> ) -> CppBox<QJsonValue>

Creates a value of type String, with value s.

Calls C++ function: [constructor] void QJsonValue::QJsonValue(QLatin1String s).

C++ documentation:

Creates a value of type String, with value s.

source

pub unsafe fn from_char(s: *const c_char) -> CppBox<QJsonValue>

Creates a value of type String with value s, assuming UTF-8 encoding of the input.

Calls C++ function: [constructor] void QJsonValue::QJsonValue(const char* s).

C++ documentation:

Creates a value of type String with value s, assuming UTF-8 encoding of the input.

You can disable this constructor by defining QT_NO_CAST_FROM_ASCII when you compile your applications.

This function was introduced in Qt 5.3.

source

pub unsafe fn from_q_json_array( a: impl CastInto<Ref<QJsonArray>> ) -> CppBox<QJsonValue>

Creates a value of type Array, with value a.

Calls C++ function: [constructor] void QJsonValue::QJsonValue(const QJsonArray& a).

C++ documentation:

Creates a value of type Array, with value a.

source

pub unsafe fn from_q_json_object( o: impl CastInto<Ref<QJsonObject>> ) -> CppBox<QJsonValue>

Creates a value of type Object, with value o.

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

C++ documentation:

Creates a value of type Object, with value o.

source

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

The QJsonValue class encapsulates a value in JSON.

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

C++ documentation:

The QJsonValue class encapsulates a value in JSON.

A value in JSON can be one of 6 basic types:

JSON is a format to store structured data. It has 6 basic data types:

A value can represent any of the above data types. In addition, QJsonValue has one special flag to represent undefined values. This can be queried with isUndefined().

The type of the value can be queried with type() or accessors like isBool(), isString(), and so on. Likewise, the value can be converted to the type stored in it using the toBool(), toString() and so on.

Values are strictly typed internally and contrary to QVariant will not attempt to do any implicit type conversions. This implies that converting to a type that is not stored in the value will return a default constructed return value.

source

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

Creates a copy of other.

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

C++ documentation:

Creates a copy of other.

source

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

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 value other with this. This operation is very fast and never fails.

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

C++ documentation:

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

This function was introduced in Qt 5.10.

source

pub unsafe fn to_array_0a(&self) -> CppBox<QJsonArray>

This is an overloaded function.

Calls C++ function: QJsonArray QJsonValue::toArray() const.

C++ documentation:

This is an overloaded function.

Converts the value to an array and returns it.

If type() is not Array, a QJsonArray() will be returned.

source

pub unsafe fn to_array_1a( &self, default_value: impl CastInto<Ref<QJsonArray>> ) -> CppBox<QJsonArray>

Converts the value to an array and returns it.

Calls C++ function: QJsonArray QJsonValue::toArray(const QJsonArray& defaultValue) const.

C++ documentation:

Converts the value to an array and returns it.

If type() is not Array, the defaultValue will be returned.

source

pub unsafe fn to_bool_1a(&self, default_value: bool) -> bool

Converts the value to a bool and returns it.

Calls C++ function: bool QJsonValue::toBool(bool defaultValue = …) const.

C++ documentation:

Converts the value to a bool and returns it.

If type() is not bool, the defaultValue will be returned.

source

pub unsafe fn to_bool_0a(&self) -> bool

Converts the value to a bool and returns it.

Calls C++ function: bool QJsonValue::toBool() const.

C++ documentation:

Converts the value to a bool and returns it.

If type() is not bool, the defaultValue will be returned.

source

pub unsafe fn to_double_1a(&self, default_value: c_double) -> c_double

Converts the value to a double and returns it.

Calls C++ function: double QJsonValue::toDouble(double defaultValue = …) const.

C++ documentation:

Converts the value to a double and returns it.

If type() is not Double, the defaultValue will be returned.

source

pub unsafe fn to_double_0a(&self) -> c_double

Converts the value to a double and returns it.

Calls C++ function: double QJsonValue::toDouble() const.

C++ documentation:

Converts the value to a double and returns it.

If type() is not Double, the defaultValue will be returned.

source

pub unsafe fn to_int_1a(&self, default_value: c_int) -> c_int

Converts the value to an int and returns it.

Calls C++ function: int QJsonValue::toInt(int defaultValue = …) const.

C++ documentation:

Converts the value to an int and returns it.

If type() is not Double or the value is not a whole number, the defaultValue will be returned.

source

pub unsafe fn to_int_0a(&self) -> c_int

Converts the value to an int and returns it.

Calls C++ function: int QJsonValue::toInt() const.

C++ documentation:

Converts the value to an int and returns it.

If type() is not Double or the value is not a whole number, the defaultValue will be returned.

source

pub unsafe fn to_object_0a(&self) -> CppBox<QJsonObject>

This is an overloaded function.

Calls C++ function: QJsonObject QJsonValue::toObject() const.

C++ documentation:

This is an overloaded function.

Converts the value to an object and returns it.

If type() is not Object, the QJsonObject() will be returned.

source

pub unsafe fn to_object_1a( &self, default_value: impl CastInto<Ref<QJsonObject>> ) -> CppBox<QJsonObject>

Converts the value to an object and returns it.

Calls C++ function: QJsonObject QJsonValue::toObject(const QJsonObject& defaultValue) const.

C++ documentation:

Converts the value to an object and returns it.

If type() is not Object, the defaultValue will be returned.

source

pub unsafe fn to_string_0a(&self) -> CppBox<QString>

Converts the value to a QString and returns it.

Calls C++ function: QString QJsonValue::toString() const.

C++ documentation:

Converts the value to a QString and returns it.

If type() is not String, a null QString will be returned.

See also QString::isNull().

source

pub unsafe fn to_string_1a( &self, default_value: impl CastInto<Ref<QString>> ) -> CppBox<QString>

Converts the value to a QString and returns it.

Calls C++ function: QString QJsonValue::toString(const QString& defaultValue) const.

C++ documentation:

Converts the value to a QString and returns it.

If type() is not String, the defaultValue will be returned.

source

pub unsafe fn to_variant(&self) -> CppBox<QVariant>

Converts the value to a QVariant().

Calls C++ function: QVariant QJsonValue::toVariant() const.

C++ documentation:

Converts the value to a QVariant().

The QJsonValue types will be converted as follows:

See also fromVariant().

source

pub unsafe fn type_(&self) -> Type

Returns the type of the value.

Calls C++ function: QJsonValue::Type QJsonValue::type() const.

C++ documentation:

Returns the type of the value.

See also QJsonValue::Type.

Trait Implementations§

source§

impl CppDeletable for QJsonValue

source§

unsafe fn delete(&self)

Destroys the value.

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

C++ documentation:

Destroys the value.

source§

impl PartialEq<Ref<QJsonValue>> for QJsonValue

source§

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

Returns true if the value is equal to other.

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

C++ documentation:

Returns true if the value is equal to other.

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.

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.