summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/json
Commit message (Collapse)AuthorAgeFilesLines
* Improve symmetry of variant json conversionsAllan Sandfeld Jensen2017-07-251-21/+49
| | | | | | | | Make QVariant::toJsonValue do conversions as well as QJsonValue::fromVariant. Change-Id: I175d43677061470691e2e0104a800be355fbbd3d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* json: Add operator[] to QJsonDocument for implicit object and array accessTor Arne Vestbø2017-06-081-0/+20
| | | | | | | | | | | Makes it easier to pull out data from a document when the structure is known up front, while still supporting default values if the structure does not match the expectation, eg: int age = QJsonDocument::fromJson(ba)["users"][0]["age"].toInt(-1); Change-Id: Ief0899bbb81610f6f22a56e2ac846121bffe77a0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* json: Add operator[] to QJsonValue for implicit object and array accessTor Arne Vestbø2017-06-081-0/+30
| | | | | | | | Saves a lot of manual toArray() and toObject() calls when the JSON structure is usually known anyways. Read only access for now. Change-Id: I5fd787144198e0443e4da285a11ce2597b66f99f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.8' into 5.9Liang Qi2017-03-271-0/+29
|\ | | | | | | Change-Id: Icdd71e9713725bda9c305e338f5c8b41a92ed8e8
| * json encoder: Harmonize number serialization with ES6Marius Kittler2017-03-251-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | Ensures that numbers representable as 64-bit integer are not printed using exponent notation. Some JSON implementations such as the one of the Go standard library expect this in the default conversion to int. Change-Id: Ic3ac718b7fd36462b4fcabbfb100a528a87798c8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-11-1729-3/+53
|\| | | | | | | | | | | | | | | Conflicts: mkspecs/features/mac/default_post.prf mkspecs/features/uikit/default_post.prf Change-Id: I2a6f783451f2ac9eb4c1a050f605435d2dacf218
| * Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-11-1629-0/+16
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/common/linux-android.conf src/gui/opengl/qopengl.h src/network/socket/qnativesocketengine_winrt.cpp src/network/socket/qnativesocketengine_winrt_p.h src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/eglfs/api/qeglfsintegration.cpp src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp sync.profile Change-Id: If70aaf2c49df91157b864cf0d7d9513546c9bec4
| | * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-11-1529-0/+16
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure src/plugins/platforms/eglfs/qeglfsintegration.cpp src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp Change-Id: Id2da7c775439adb62646d5b741ee7c638042b34b
| | | * Improve the validation algorithm for binary JSONLars Knoll2016-11-1129-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add better boundary checks and catch (hopefully all) cases where invalid binary JSON could cause crashes. Change-Id: I206510b7c5e3ba953802a5f46645878e65704ecc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| | | * Update testdataMaurice Kalinowski2016-02-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some entries were not updated and tests failed to succeed on platforms which need to deploy content/testdata. Change-Id: Ieb2b44c375b04cbaaecc1fb2303cc2478b86a100 Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
| * | | Improve error offset in JSON parsingAllan Sandfeld Jensen2016-11-151-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Do not consume white-space after a token before the token has been parsed, otherwise we end up with misleading offsets. This also fixes a wrong error of illegal number in several cases. Change-Id: I492ca4de0346a1d0ab73b1c23d7a72dba812664c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
| * | | QVariant to QJsonValue::Null conversionAllan Sandfeld Jensen2016-11-081-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds a few missing parts of the conversion from QVariant to QJsonValue after the introduction of the nullptr QVariant. The conversion the other way is already implemented. Change-Id: I8b25dec4b476c4761c5098a60944ff11c36f8bec Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | | | macOS: Don't build auto-tests as application bundles unless explicitly requestedTor Arne Vestbø2016-10-231-1/+0
|/ / / | | | | | | | | | | | | | | | | | | | | | Consistent with other Unix platforms, and internally consistent between tests, as a lot of tests were already applying CONFIG -= app_bundle manually. Change-Id: Icd2b7e1c08015b26137af60ff82fddbc753f0ff4 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* | | Modularize configure.json/.priLars Knoll2016-09-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the different parts of configure.json/.pri into the libraries where they belong. Gui is not yet fully modularized, and contains many things related to the different QPA plugins. Done-with: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Change-Id: I6659bb29354ed1f36b95b8c69e7fce58f642053f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | tests/auto/corelib/json: clean upMarc Mutz2016-08-271-2/+3
| | | | | | | | | | | | | | | | | | | | | Just one Q_FOREACH needed porting to C++11 range-for here. Change-Id: I30ddd2a80cbb3245e23accc7843e67574fb2db17 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Use qtConfig throughout in qtbaseLars Knoll2016-08-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use the new qtConfig macro in all pro/pri files. This required adding some feature entries, and adding {private,public}Feature to every referenced already existing entry. Change-Id: I164214dad1154df6ad84e86d99ed14994ef97cf4 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* | | QJsonValue::toVariant(): Differentiate between null and invalidChristian Kandeler2016-08-051-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both were mapped to QVariant() before. Instead, use a null pointer QVariant for a null JSON value. [ChangeLog][QtCore][QJsonValue] QJsonValue(Null).toVariant() now returns a QVariant of type QMetaType::Nullptr instead of an invalid QVariant. Task-number: QTBUG-43077 Change-Id: Ife611f418583dbff542210bc8c5cd65201212a6e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Handle QVariantHash in QJsonDocument::fromVariantAllan Sandfeld Jensen2016-07-131-0/+40
|/ / | | | | | | | | | | | | | | | | | | | | It absence is just an oversight. The patch also adds test for the valid inputs of the method. [ChangeLog][QtCore][QJsonDocument] fromVariant can now take a QVariantHash argument. Task-number: QTBUG-39751 Change-Id: I7e051413f930023db3cbb81452e77c56a7ceffe8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QJsonObject: add some overloads taking QLatin1StringMarc Mutz2016-05-101-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QXmlStreamReader also has QLatin1String overloads, which greatly benefits parsers, since the vast majority of keys in both JSON and XML are US-ASCII. This patch adds such an overload to the JSON parser. The value() function is all typical parsers need, so even though many more QJsonObject functions taking QString could benefit from the same treatment, value() is the single most important one for read-only JSON access. Add some more overloads, too, for functions that don't need more internal scaffolding than value(). Requires adding a dummy op[](QL1S) (forwarding to the QString overload) so as not to make QJsonObject json; json[QLatin1String("key")]; // mutable ambiguous between const op[](QL1S) and mutable op[](QString). [ChangeLog][QtCore][QJsonObject] Added value(), op[] const, find(), constFind(), contains() overloads taking QLatin1String. Change-Id: I00883028956ad949ba5ba2b18dd8a6a25ad5085b Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Updated license headersJani Heikkinen2016-01-211-17/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some exceptions, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one (in those files which will be under GPL 3 with exceptions) Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.6' into devFrederik Gladhorn2016-01-081-0/+6
|\| | | | | | | | | | | Based on merge done by Liang Qi Change-Id: Id566e5b9f284d29bff2199f13f9417c660f5b26f
| * Fix QJsonValue::fromVariant() if the variant contains a json objectLars Knoll2015-12-221-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | If the variant contains a known json type (value, array, object or document), simply unwrap those. In the case of the json document wrap the contained object/array into a QJsonValue. This should be the expected behavior, and makes more sense than returning a null QJsonValue. Task-number: QTBUG-41234 Change-Id: Id084fc11220d51aaf78b7694fd0ebef1411f5c51 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Sanitize JSON test datahjk2015-12-162-5/+5
| | | | | | | | | | | | | | Strings do not have to be overly specific to test parser function. Change-Id: I345dfec7fb4b8004661f6757cfd53b428ad87b6b Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Tests: Remove empty init/cleanup slots, constructors and destructors.Friedemann Kleint2015-12-101-21/+0
| | | | | | | | | | | | | | | | Move some code (like registrations of meta types) from init() to initTestCase() in the process. Change-Id: I57db5156647cfadab554fbed853b2e68b2815f3b Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
* | Use "shortest" double conversion for JSONUlf Hermann2015-11-232-3/+17
| | | | | | | | | | | | Task-number: QTBUG-42419 Change-Id: I649c4de96a2e41078e139c0f382e5a6cf96d3bb9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Add a file to the TESTDATA listJames McDonnell2015-11-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The file exists and it's listed in json.qrc (for Android) but it isn't listed in TESTDATA. This is only a problem when the target is a another system as is the case with Qt for QNX. One of the tests fails because the file isn't deployed. Noticed this while testing the changes for custom spacing of JSON output. Task-number: QTBUG-47437 Change-Id: I627592a5a225f50fdb8e3cdd6ac72dff43936ae5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Tests: Fix single-character string literals.Friedemann Kleint2015-10-131-6/+6
| | | | | | | | | | | | | | Use character literals where applicable. Change-Id: I1a026c320079ee5ca6f70be835d5a541deee2dd1 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Tests: Remove CONFIG += parallel_test.Friedemann Kleint2015-09-051-1/+0
| | | | | | | | | | | | | | The keyword no longer has a meaning for the new CI. Change-Id: Ibcea4c7a82fb7f982cf4569fdff19f82066543d1 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Remove QT_DISABLE_DEPRECATED_BEFORE=0 from tests not using deprecated API.Friedemann Kleint2015-09-011-1/+0
| | | | | | | | | | Change-Id: I1955320e7639760b4383a53f37a506c8055933ef Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
* | tests/corelib: Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b).Friedemann Kleint2015-08-191-45/+45
|/ | | | | | | | | | | | | | - Replace Q[TRY]_VERIFY(pointer == 0) by Q[TRY]_VERIFY(!pointer). - Replace Q[TRY]_VERIFY(smartPointer == 0) by Q[TRY]_VERIFY(smartPointer.isNull()). - Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b) and add casts where necessary. The values will then be logged should a test fail. Tests from corelib/tools were omitted in this change. Change-Id: I4c8786d33fcf429d11b2b624c7cd89c28cadb518 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make sure remove() doesn't corrupt the json objectLars Knoll2015-03-181-0/+21
| | | | | | | | | When using non latin keys, remove() could cause corruption of the json object. Task-number: QTBUG-42270 Change-Id: I7305e57ebb78630a9bf68bc4f831a6d1646abb79 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.4' into 5.5Frederik Gladhorn2015-02-241-0/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/xml/htmlinfo/simpleexample.html examples/xml/rsslisting/rsslisting.cpp qmake/generators/win32/msbuild_objectmodel.cpp src/3rdparty/harfbuzz-ng/src/hb-private.hh src/corelib/global/qlogging.cpp src/corelib/io/qstorageinfo_unix.cpp src/corelib/thread/qwaitcondition_unix.cpp src/gui/kernel/qguiapplication.cpp src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp src/testlib/doc/src/qt-webpages.qdoc tests/auto/other/qaccessibility/tst_qaccessibility.cpp Change-Id: Ib272ff0bc30a1a5d51275eb3cd2f201dc82c11ff
| * Document and further test that QJsonObject::keys() is sorted.Mitch Curtis2015-02-111-0/+2
| | | | | | | | | | Change-Id: I6b145c1240cce85ad3fea6fb90ddbed629487f83 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* | QtCore: Use QDebugStateSaver in (almost) all QDebug operator<<Kai Koehne2015-02-091-2/+2
| | | | | | | | | | | | | | | | | | Unify the behavior of the different operator<< by always using QDebugStateSaver (appending an optional space at exit), and making sure that the space(), nospace() setting isn't 'leaked'. Change-Id: I38e4f82fa6f7419d8b5edfc4dc37495af497e8ac Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.4' into devFrederik Gladhorn2014-12-292-2/+12
|\| | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qbytearray.cpp src/gui/kernel/qplatformsystemtrayicon.cpp src/gui/kernel/qplatformsystemtrayicon.h src/plugins/platforms/xcb/xcb-plugin.pro Change-Id: I00355d3908b678af8a61c38f9e814a63df808c79
| * Android: Fix json test.BogDan Vatra2014-12-222-2/+12
| | | | | | | | | | | | | | Add test data to resources. Change-Id: Ib8a5688e7caab8434b8f0676f53a2a79ec94b264 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* | Add conversion between QVariantHash and QJsonObjectAllan Sandfeld Jensen2014-10-301-0/+42
|/ | | | | | | | | | | Adds automatic conversion from QVariants with a QVariantHash to QJsonValue and explicit methods for conversion between QVariantHash and QJsonObject. [ChangeLog][QtCore][QJsonObject] Added conversion to and from QVariantHash Change-Id: I140ef881463acabaab2648e28209487d8ad18e0d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Fix MSVC source code encoding warnings in tst_qtjson.Friedemann Kleint2014-09-231-3/+3
| | | | | | | | | | tst_qtjson.cpp(2711) : warning C4566: character represented by universal-character-name '\u2090' cannot be represented in the current code page (1252) tst_qtjson.cpp(2712) : warning C4566: character represented by universal-character-name '\u2090' cannot be represented in the current code page (1252) tst_qtjson.cpp(2713) : warning C4566: character represented by universal-character-name '\u2090' cannot be represented in the current code page (1252) Task-number: QTBUG-41100 Change-Id: I193dc48236bdd3857657a5684178630f0e1dab6d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Revert "Reading QJsonObject property should not modify the object itself."Jędrzej Nowacki2014-09-111-51/+0
| | | | | | | | | | This reverts commit 20cf632ad5f3ffe7b0fd231724c971f4e07304eb. The commit produced to many problems during statics destruction. For example causing QtCreator crash (QTBUG-40987). Change-Id: Ib52f6a449c2d84deab2de792559a6a065ca45e8d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Don't accept json strings with trailing garbageLars Knoll2014-09-101-0/+14
| | | | | | | | | | A well formed JSON document is not allowed to contain trailing garbage at the end. Don't accept this in the parser. Task-number: QTBUG-40062 Change-Id: I0a09dbd099a8c643f58023342546c4e67d026fec Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Fix bugs in internal comparison operatorsLars Knoll2014-09-101-0/+24
| | | | | | | | | | | The comparison operators between QJsonPrivate::String and QJsonPrivate::Latin1String weren't all correct, leading to wrong sorting of keys in QJsonObjects when the keys were outside of the latin1 range and resulting lookup errors. Task-number: QTBUG-41100 Change-Id: Idceff615f85d7ab874ad2a8e4a6c1ce8c2aa0f65 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Add operator-> to QJson iteratorsAllan Sandfeld Jensen2014-08-251-0/+4
| | | | | | | | | | | | | The iterators for QJsonArray and QJsonObject are currently lacking an operator-> definition. Unfortunately it is not possible to do in clean way without redefining either the iterators or QJsonValueRef class. This patch instead adds two fake pointer classes that are only used to handle the operator-> return value. Task-number: QTBUG-29573 Change-Id: Ief785a6afbbedc9e89cf3b6f3958c2c755997a66 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add initializer list support in QJsonObject.Jędrzej Nowacki2014-07-301-2/+53
| | | | | | | | | | | | | | It allows to create a QJsonObject instance in C++ by using initializer list of pairs QString QJsonValue, for example: QJsonObject o = {{"property1", 1}, {"property2", 2}}; [ChangeLog][QtCore][QtJson] QJsonObject now supports C++11 initializer lists. Task-number: QTBUG-26606 Change-Id: I67af881e175f427e563e685336c48a5f8466b476 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QJsonValue comparison.Jędrzej Nowacki2014-07-251-0/+55
| | | | | | | | | QJsonValue, while comparing two QJsonArrays, should consult also length of the arrays, because a different than null base pointer doesn't mean that an array is not empty. Change-Id: If76739355a4e74b842e836289565f98d95c006d5 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix QJsonValue comparison.Jędrzej Nowacki2014-07-251-4/+10
| | | | | | | | | QJsonValue, while comparing two QJsonObjects, should consult also length of the objects, because a different than null base pointer doesn't mean that an object is not empty. Change-Id: Ibee1849ef9fed15d32f2c8f2aad9b053846e46b7 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Reading QJsonObject property should not modify the object itself.Jędrzej Nowacki2014-07-251-0/+124
| | | | | | | | | | | | | | | | | | | | | | | | | Before this change such code: QJsonObject o; o["blah"]; would create property "blah" and assign null value to it, while this code: const QJsonObject o; o["blah"]; would not. The change unifies the confusing behavior. Now reading a non-existing property, is not causing a property to be added in any visible way. Internally QJsonObject stores a special hash of undefined, but referenced values. Such reference is supposed to not live long, only to the first compacting or assignment. Change-Id: Ib022acf74ff49bad88d45d65d7093c4281d468f1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix QJsonObject const index operatorJędrzej Nowacki2014-07-251-0/+18
| | | | | | | | | The operator should always return an undefined values for an empty object Change-Id: Ic38f7660d77c64b2d001967bc5109df4185db74a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add initializer list support in QJsonArrayJędrzej Nowacki2014-07-041-0/+52
| | | | | | | | | | | | | | It allows to create a QJsonArray instance in C++ by using a similar expression to JSON. For example: QJsonArray a = {1, 2, 4}; [ChangeLog][QtCore][QtJson] QJsonArray now supports C++11 initializer lists. Task-number: QTBUG-26606 Change-Id: Icc352e518d9649d24176c89e7113d200d5c50b0d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>