path: root/src/corelib/json/qjsondocument.h
diff options
authorJean-Paul Delimat <>2012-12-28 01:23:16 +0100
committerThe Qt Project <>2013-01-26 03:09:27 +0100
commit4bb5566632ea6510c67fb8cf28cfe7dd4801488f (patch)
treeeea1eef7e3a4e0e5f250c84f1b84f16a5fefa667 /src/corelib/json/qjsondocument.h
parente335fb7254ad6c2ce08eda0d092ea524a302c2e0 (diff)
Add toJson() formatting argument to QJsonDocument interface
The writer delegate used by QJsonDocument to produce a Json QByteArray supports generating a human readable Json (with spaces and carriage returns that reflect the Json structure) and a less human readable (no spaces nor carriage returns) but more compact Json. The method toJson() was extended with a format argument to support the compact Json generation. Task-number: QTBUG-28815 Change-Id: I8d13849ab9ab6ed7c645011260251dc14a8629d2 Reviewed-by: Lars Knoll <> Reviewed-by: Thiago Macieira <> Reviewed-by: Debao Zhang <>
Diffstat (limited to 'src/corelib/json/qjsondocument.h')
1 files changed, 12 insertions, 1 deletions
diff --git a/src/corelib/json/qjsondocument.h b/src/corelib/json/qjsondocument.h
index 675ee75dbf..0bb21d89cf 100644
--- a/src/corelib/json/qjsondocument.h
+++ b/src/corelib/json/qjsondocument.h
@@ -109,8 +109,19 @@ public:
static QJsonDocument fromVariant(const QVariant &variant);
QVariant toVariant() const;
+ enum JsonFormat {
+ Indented,
+ Compact
+ };
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = 0);
- QByteArray toJson() const;
+#ifdef Q_QDOC
+ QByteArray toJson(JsonFormat format = Indented) const;
+ QByteArray toJson() const; //### Merge in Qt6
+ QByteArray toJson(JsonFormat format) const;
bool isEmpty() const;
bool isArray() const;