From 653db8f4bfed293ee0f69f7bb71e3d836286f445 Mon Sep 17 00:00:00 2001 From: nowrep Date: Tue, 11 Feb 2014 15:34:51 +0100 Subject: [PATCH] [Json] Implement bool values This fixes expanded state with QScriptEngine Json parsing --- src/lib/tools/json.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib/tools/json.cpp b/src/lib/tools/json.cpp index 3a4c762e5..c3f1e68aa 100644 --- a/src/lib/tools/json.cpp +++ b/src/lib/tools/json.cpp @@ -82,6 +82,9 @@ QMap Json::decodeInner(QScriptValue object) else if (it.value().isString()) { map.insert(it.name(), QVariant(it.value().toString())); } + else if (it.value().isBool()) { + map.insert(it.name(), QVariant(it.value().toBool())); + } else if (it.value().isNull()) { map.insert(it.name(), QVariant()); } @@ -114,6 +117,9 @@ QList Json::decodeInnerToList(QScriptValue arrayValue) else if (it.value().isString()) { list.append(QVariant(it.value().toString())); } + else if (it.value().isBool()) { + list.append(QVariant(it.value().toBool())); + } else if (it.value().isNull()) { list.append(QVariant()); } @@ -139,6 +145,9 @@ QScriptValue Json::encodeInner(const QMap &map) else if (i.value().type() == QVariant::Int) { obj.setProperty(i.key(), i.value().toInt()); } + else if (i.value().type() == QVariant::Bool) { + obj.setProperty(i.key(), i.value().toBool()); + } else if (i.value().type() == QVariant::Double) { obj.setProperty(i.key(), i.value().toDouble()); }