diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2020-06-27 10:40:37 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2020-07-02 10:32:13 -0700 |
commit | 0d55d1c640eff6b1bb9fcfa8f9130635782e0c97 (patch) | |
tree | 12be5c8e812977e02487a2625ee89987f01a019d /src/corelib/serialization/qjsoncbor.cpp | |
parent | 634ce491e8e943519593140b858eb2e67253c13e (diff) |
Doc: improve documentation about QVariant to JSON lossy conversions
Fixes: QTBUG-85299
Pick-to: 5.15
Change-Id: I24006db8360041f598c5fffd161c77638a54a27e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/corelib/serialization/qjsoncbor.cpp')
-rw-r--r-- | src/corelib/serialization/qjsoncbor.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/corelib/serialization/qjsoncbor.cpp b/src/corelib/serialization/qjsoncbor.cpp index 8bb04fa3bf..e0eab74a02 100644 --- a/src/corelib/serialization/qjsoncbor.cpp +++ b/src/corelib/serialization/qjsoncbor.cpp @@ -679,17 +679,22 @@ static void appendVariant(QCborContainerPrivate *d, const QVariant &variant) \row \li \l QUuid \li Uuid \endtable - For any other types, this function will return Null if the QVariant itself - is null, and otherwise will try to convert to string using - QVariant::toString(). If the conversion to string fails, this function - returns Undefined. + If QVariant::isNull() returns true, a null QCborValue is returned or + inserted into the list or object, regardless of the type carried by + QVariant. Note the behavior change in Qt 6.0 affecting QVariant::isNull() + also affects this function. + + For other types not listed above, a conversion to string will be attempted, + usually but not always by calling QVariant::toString(). If the conversion + fails the value is replaced by an Undefined CBOR value. Note that + QVariant::toString() is also lossy for the majority of types. Please note that the conversions via QVariant::toString() are subject to - change at any time. QCborValue may be extended in the future to support - more types, which will result in a change in how this function performs - conversions. + change at any time. Both QVariant and QCborValue may be extended in the + future to support more types, which will result in a change in how this + function performs conversions. - \sa toVariant(), fromJsonValue(), QCborArray::toVariantList(), QCborMap::toVariantMap() + \sa toVariant(), fromJsonValue(), QCborArray::toVariantList(), QCborMap::toVariantMap(), QJsonValue::fromVariant() */ QCborValue QCborValue::fromVariant(const QVariant &variant) { |