diff options
| author | Ivan Solovev <ivan.solovev@qt.io> | 2024-12-18 15:32:02 +0100 |
|---|---|---|
| committer | Ivan Solovev <ivan.solovev@qt.io> | 2025-01-02 13:07:21 +0100 |
| commit | 3cb87d891bb040f73fb68b6c5e7e82518f603c59 (patch) | |
| tree | b33a3dbff6f991561ba16b719ec5fbade8f1167d /src/corelib/serialization/qjsonvalue.cpp | |
| parent | fecae6ab1b1aa36f43b5cd87b229de4df37e44ab (diff) | |
Do not duplicate JsonFormat enum
The enum already exists in QJsonDocument, so there is no reason to
introduce a new one in QJsonValue.
Instead, use the fact that we only need to forward-declare QJsonValue
in QJsonDocument's header, include the latter into qjsonvalue.h, and
use a type alias.
For Qt 7, pre-program moving of the enum into QJsonValue and using
an alias in QJsonDocument.
Amends ac73079dee5f0260528a5c217a82cb0beafb0a56.
Found in Qt 6.9 API review.
[ChangeLog][QtCore][Potentially Source-Incompatible Changes] The
QJsonDocument header no longer includes QJsonValue.
The backward-compatible fix is to include all needed headers
explicitly and to not rely on the transitive includes.
Pick-to: 6.9
Change-Id: I7c5219a239149e4a87d4780c4277d111983ad0f4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization/qjsonvalue.cpp')
| -rw-r--r-- | src/corelib/serialization/qjsonvalue.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/corelib/serialization/qjsonvalue.cpp b/src/corelib/serialization/qjsonvalue.cpp index 1ae6cef7ef2..199e5d3154b 100644 --- a/src/corelib/serialization/qjsonvalue.cpp +++ b/src/corelib/serialization/qjsonvalue.cpp @@ -616,6 +616,7 @@ QJsonValue QJsonValue::fromJson(QByteArrayView json, QJsonParseError *error) } /*! +\if defined(qt7) \enum QJsonValue::JsonFormat \since 6.9 @@ -627,7 +628,13 @@ QJsonValue QJsonValue::fromJson(QByteArrayView json, QJsonParseError *error) \value Compact Defines a compact output as follows: \snippet code/src_corelib_serialization_qjsondocument.cpp 1 - */ +\else + \typealias QJsonValue::JsonFormat + \since 6.9 + + Same as \l QJsonDocument::JsonFormat. +\endif +*/ /*! \since 6.9 @@ -640,7 +647,7 @@ QByteArray QJsonValue::toJson(JsonFormat format) const { QByteArray json; - QJsonPrivate::Writer::valueToJson(value, json, 0, (format == Compact)); + QJsonPrivate::Writer::valueToJson(value, json, 0, (format == JsonFormat::Compact)); return json; } |
