diff options
-rw-r--r-- | src/qml/qml/v4/qv4jsonobject.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/qml/qml/v4/qv4jsonobject.cpp b/src/qml/qml/v4/qv4jsonobject.cpp index 1d83a0d2e5..34f4809fd2 100644 --- a/src/qml/qml/v4/qv4jsonobject.cpp +++ b/src/qml/qml/v4/qv4jsonobject.cpp @@ -992,7 +992,8 @@ QJsonObject JsonObject::toJsonObject(QV4::Object *o, V4ObjectSet &visitedObjects break; QString key = name.toQString(); - result.insert(key, toJsonValue(v, visitedObjects)); + if (!v.asFunctionObject()) + result.insert(key, toJsonValue(v, visitedObjects)); } visitedObjects.remove(o); @@ -1030,7 +1031,7 @@ QJsonArray JsonObject::toJsonArray(ArrayObject *a, V4ObjectSet &visitedObjects) quint32 length = a->arrayLength(); for (quint32 i = 0; i < length; ++i) { Value v = a->getIndexed(i); - result.append(toJsonValue(v, visitedObjects)); + result.append(toJsonValue(v.asFunctionObject() ? QV4::Value::nullValue() : v, visitedObjects)); } visitedObjects.remove(a); diff --git a/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp b/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp index e6b056fbd0..aaeecb9fc9 100644 --- a/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp +++ b/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp @@ -428,7 +428,7 @@ void tst_qjsonbinding::writeProperty_javascriptExpression_data() QTest::newRow("object = object with function property") << "object" << "{ foo: function() {} }" << "{}"; QTest::newRow("array = array with function property") - << "array" << "[function() {}]" << "[]"; + << "array" << "[function() {}]" << "[null]"; // Inherited properties should not be included. QTest::newRow("value = object with inherited property") |