Utils: Use QJsonDocument instead of QScriptEngine for json parsing

That lets us remove the dependency to QtScript

Change-Id: I54e1e5b74782073a36daa2a4b4c3547925de4ca8
Reviewed-by: hjk <hjk@theqtcompany.com>
Reviewed-by: Marco Benelli <marco.benelli@theqtcompany.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
This commit is contained in:
Alessandro Portale
2015-03-18 13:44:43 +01:00
committed by Erik Verbruggen
parent dc703a902e
commit 6ea6e9e5ce
2 changed files with 5 additions and 7 deletions

View File

@@ -36,7 +36,7 @@
#include <QDir>
#include <QStringBuilder>
#include <QDebug>
#include <QScriptEngine>
#include <QJsonDocument>
using namespace Utils;
@@ -57,13 +57,11 @@ JsonValue::~JsonValue()
JsonValue *JsonValue::create(const QString &s, JsonMemoryPool *pool)
{
QScriptEngine engine;
QScriptValue jsonParser = engine.evaluate(QLatin1String("JSON.parse"));
QScriptValue value = jsonParser.call(QScriptValue(), QScriptValueList() << s);
if (engine.hasUncaughtException() || !value.isValid())
const QJsonDocument document = QJsonDocument::fromJson(s.toUtf8());
if (document.isNull())
return 0;
return build(value.toVariant(), pool);
return build(document.toVariant(), pool);
}
void *JsonValue::operator new(size_t size, JsonMemoryPool *pool)