summaryrefslogtreecommitdiffstats
path: root/src/corelib/json/qjsondocument.cpp
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2013-09-05 07:55:49 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-17 08:07:25 +0200
commit89ef515177fd5a0b5d95dcffd5fd0b0669e3625a (patch)
tree0fb87c82c882168141c1194dabbc47915f10eb98 /src/corelib/json/qjsondocument.cpp
parentf47958fa148d6ea9ece0bec3ca9ba67d9c68ea19 (diff)
Add JSON parsing support to qmake.
Add qjson* implementation files from corelib/json to the qmake build. Add a read-only compile mode, enabled by defining QT_JSON_READONLY. Add qmake built-in function parseJson(file, into) which parses a json file into the given variable. qmake uses a flat key -> value-list implementation for storing variables, which means that some hackery is need to represent arbitrarily nested JSON. Use a special "_KEYS_" variable for arrays and objects: Arrays: ["item1", "item2"] $${array._KEYS_} -> 0 1 2 $${array.0} -> "item1" $${array.1} -> "item2" Objects: { "key1" : "value1", "key2" : "value2" } $${object._KEYS_} -> key1 key2 $${object.key1} -> value1 $${object.key2} -> value2 Change-Id: I0aa2e4e4ae14fa25be8242bc16d3cffce32504d2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib/json/qjsondocument.cpp')
-rw-r--r--src/corelib/json/qjsondocument.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/corelib/json/qjsondocument.cpp b/src/corelib/json/qjsondocument.cpp
index 4806ac68d6..6e257df39d 100644
--- a/src/corelib/json/qjsondocument.cpp
+++ b/src/corelib/json/qjsondocument.cpp
@@ -303,10 +303,12 @@ QVariant QJsonDocument::toVariant() const
\sa fromJson()
*/
+#ifndef QT_JSON_READONLY
QByteArray QJsonDocument::toJson() const
{
return toJson(Indented);
}
+#endif
/*!
\enum QJsonDocument::JsonFormat
@@ -338,6 +340,7 @@ QByteArray QJsonDocument::toJson() const
\sa fromJson(), JsonFormat
*/
+#ifndef QT_JSON_READONLY
QByteArray QJsonDocument::toJson(JsonFormat format) const
{
if (!d)
@@ -352,6 +355,7 @@ QByteArray QJsonDocument::toJson(JsonFormat format) const
return json;
}
+#endif
/*!
Parses a UTF-8 encoded JSON document and creates a QJsonDocument
@@ -562,7 +566,7 @@ bool QJsonDocument::isNull() const
return (d == 0);
}
-#ifndef QT_NO_DEBUG_STREAM
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY)
QDebug operator<<(QDebug dbg, const QJsonDocument &o)
{
if (!o.d) {