[][src]Struct qt_core::QJsonValue

#[repr(C)]pub struct QJsonValue { /* fields omitted */ }

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.

Methods

impl QJsonValue[src]

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

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.

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

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

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

This is supported 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.

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

This is supported 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.

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

This is supported 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.

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

This is supported 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.

pub unsafe fn is_array(&self) -> bool[src]

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

pub unsafe fn is_bool(&self) -> bool[src]

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

pub unsafe fn is_double(&self) -> bool[src]

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

pub unsafe fn is_null(&self) -> bool[src]

Returns true if the value is null.

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

C++ documentation:

Returns true if the value is null.

pub unsafe fn is_object(&self) -> bool[src]

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

pub unsafe fn is_string(&self) -> bool[src]

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

pub unsafe fn is_undefined(&self) -> bool[src]

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.

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

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.

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

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.

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

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.

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

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.

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

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.

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

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.

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

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.

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

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.

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

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.

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

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.

pub unsafe fn new() -> CppBox<QJsonValue>[src]

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.

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

Creates a copy of other.

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

C++ documentation:

Creates a copy of other.

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

This is supported 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.

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

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.

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

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.

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

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.

pub unsafe fn to_bool_0a(&self) -> bool[src]

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.

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

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.

pub unsafe fn to_double_0a(&self) -> c_double[src]

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.

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

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.

pub unsafe fn to_int_0a(&self) -> c_int[src]

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.

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

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.

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

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.

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

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

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

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.

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

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

pub unsafe fn type_(&self) -> Type[src]

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

impl CppDeletable for QJsonValue[src]

unsafe fn delete(&self)[src]

Destroys the value.

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

C++ documentation:

Destroys the value.

impl PartialEq<Ref<QJsonValue>> for QJsonValue[src]

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

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.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.