summaryrefslogtreecommitdiffstats
path: root/src/corelib/json
Commit message (Collapse)AuthorAgeFilesLines
* Fix parsing of long latin strings in the json parserLars Knoll2013-05-231-1/+2
| | | | | | | | | | | Latin1 strings are usually stored as 8 bit data in the json binary format. But that data structure has a size limitation of 16bit, so we need to fall back to storing the string as 16 bit data if it is too long. Task-number: QTBUG-30946 Change-Id: I0069b1367030b0b2f819fd1f04e34c9e2534a2a3 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* QtCore: fix the number precision in QJsonDocument.toJson()Liang Qi2013-05-201-1/+1
| | | | | | | | | | | | | | In JSON, any number is stored in double. We need to make sure we keep the maximum possible number precision for integer number. In IEEE 754 double format, the significand precision is 53 bits(52 explicityly stored). Autotest is included. qint64 and double work fine. Task-number: QTBUG-28467 Change-Id: I7f857671c50e4334e9329c778f9b4f090f490540 Reviewed-by: Sune Vuorela <sune@vuorela.dk> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix crashes when creating large documentsLars Knoll2013-05-096-16/+64
| | | | | | | | | | | | | Compact an object in regular intervals when inserting data into it, to avoid the object becoming huge. Compact an object/array before inserting into another array or object. Check that the document doesn't get so big it's overflowing the internal data structures. Task-number: QTBUG-29288 Change-Id: Id39d80dac1e7d5a11f40819f41b4b336bce16947 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-294-16/+0
| | | | | | | | | | | The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
* Add toJson() formatting argument to QJsonDocument interfaceJean-Paul Delimat2013-01-262-3/+49
| | | | | | | | | | | | | | | | The writer delegate used by QJsonDocument to produce a Json QByteArray supports generating a human readable Json (with spaces and carriage returns that reflect the Json structure) and a less human readable (no spaces nor carriage returns) but more compact Json. The method toJson() was extended with a format argument to support the compact Json generation. Task-number: QTBUG-28815 Change-Id: I8d13849ab9ab6ed7c645011260251dc14a8629d2 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Debao Zhang <hello@debao.me>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-1814-14/+14
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Added missing detach() to QJsonObject::take()Denis Dzyubenko2012-12-131-2/+3
| | | | | | | | | We also need to detach() the taken value in case the compaction triggers and modifies the underlaying data. Change-Id: Idcdeba4236b8e208d107d41be2decbdfc5721300 Reviewed-by: Bjørn Erik Nilsen <post@bjoernen.com> Reviewed-by: Denis Dzyubenko <denis@ddenis.info>
* QtBase: Doc: Fix links to STL-style iteratorsDavid Schulz2012-12-062-8/+8
| | | | | Change-Id: I2822c2a7e9bfc1949c20ff81e08961f641e961fb Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Remove duplicate words and punctuation from documentation.Mitch Curtis2012-09-261-1/+1
| | | | | Change-Id: I5550c62d412510bc2c5acceb2cae7d2f2ef6a8d3 Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Fixed crash in moc on big endian platforms.Konstantin Tokarev2012-09-241-1/+1
| | | | | Change-Id: Icaa38eb4b404e5f52248fdeaf9180a5d70d0f5f2 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fixed QJsonDocument::fromBinaryData on big endian platforms.Konstantin Tokarev2012-09-242-4/+4
| | | | | Change-Id: I1786b6222867c8780f6768e5220e7ddff952b28e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fixed ifdef condition in QJson resulting in big endian breakage.Konstantin Tokarev2012-09-241-1/+1
| | | | | Change-Id: I3d36d75ff95ad2fe2fcbbe262f9782f0709d7041 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-2214-336/+336
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Removing duplicate includesSergio Ahumada2012-09-092-2/+0
| | | | | | | Do not include a header more than once Change-Id: Ia2e5d66e72988ad833cf5177a3f8aa988bf510e9 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Removed extra detach calls from QJsonArray::takeAtDenis Dzyubenko2012-08-291-6/+1
| | | | | Change-Id: I5711ec6b03e3979eca61f62004a7c6f0eaae79e0 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* doc: Fix some qdoc warningsEskil Abrahamsen Blomfeldt2012-08-231-9/+11
| | | | | | | | | | | QDoc doesn't supported nested tags, and there doesn't seem to be any way to trick it into thinking you've mentioned the argument (\omit didn't work), so actually rephrasing is the only way to kill the warning. Also add a const modifier to a signature to make it match the declaration. Change-Id: Ie02a488c42565205e827602959111c53e2d05a83 Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Doc: Add \inmodule QtCore to all QtCore class doc bodiesThiago Macieira2012-08-235-0/+10
| | | | | Change-Id: I19100755c97cc155c76a859e19940e9f9222d34e Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Fix some qdoc errors in the QJson* classesLars Knoll2012-08-202-0/+16
| | | | | Change-Id: If475655445afdba307508c5a3863c4bc8d87ebe6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make the "\internal" qdoc command stand on its own lineLaszlo Papp2012-08-151-1/+2
| | | | | | | | | | The qdoc manual currently claims that the command must stand on its own line. The change follows the consistency with the rest and how the example looks like inside the qdoc manual for this command. Change-Id: I6b653dc95cf9d84e4adf32220dace5d313678419 Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Fixed most qdoc errors for the json classes.Lars Knoll2012-07-206-39/+221
| | | | | | Change-Id: Ibbbdd7212f6c5e25422bbaa9ccaf4822db52222a Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com> Reviewed-by: Richard J. Moore <rich@kde.org>
* Fix some spelling errorsSergio Ahumada2012-07-112-2/+2
| | | | | | Change-Id: I19d3b2e9a5180b13deb828b55195404ef20be295 Reviewed-by: Daniel Teske <daniel.teske@nokia.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Fixed QJsonObject::find()Denis Dzyubenko2012-06-061-0/+1
| | | | | | | | | | The function returns mutable iterator on the object that can later be passed to e.g. erase(), hence it should detach() to be consistent with QJsonObject::begin() which also detaches. Change-Id: Id79e8e012fd5469e06b68fbc9eecb7c6848ce9c1 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
* Replace `const QLatin1String &` with `QLatin1String` where appropriateKonstantin Ritt2012-05-252-2/+2
| | | | | | | Task-Id: QTBUG-24502 Change-Id: I360dee4dc68c165de0631ce4cf34e76fd873080e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Limit the nesting depth of the Json parserLars Knoll2012-05-163-4/+47
| | | | | | | | | | | | | | | The parser is recursive and too deeply nested json would cause it to exhaust the available stack space leading to crashes. We now abort parsing with a DeepNesting parse error if the document is too deeply nested. The current nesting limit is set to 1024, which should be more then enough for any real JSON data set. Change-Id: I4adea3fd727149f7342536d73cf4530361a0a3a1 Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com> Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
* QChar: add isSurrogate() and isNonCharacter() to the public APIKonstantin Ritt2012-05-162-5/+3
| | | | | | | | + QChar::LastValidCodePoint enum value that supercede the UNICODE_LAST_CODEPOINT macro replace uses of hardcoded values with the new API; remove leftovers Change-Id: I1395c9840b85fcb6b08e241b131794a98773c952 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Correctly parse json documents with a leading BOMLars Knoll2012-05-102-2/+15
| | | | | | | | A leading byte order mark is valid in utf-8 and we should parse documents starting with those correctly. Change-Id: Id85398ff6e05b93ceefbaf4a6de5571d5e61ca13 Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
* add some useful methods to QUnicodeTables::Konstantin Ritt2012-05-102-30/+4
| | | | | | | in order to reduce code duplication and prepare the ground for upcoming changes Change-Id: I980244149f65384c9484bbec4682de8b7b848b08 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Add assignment operator for QJsonValueRefAli Akhtarzada2012-05-082-0/+11
| | | | | | | | | The implicit cast to QJsonValue was being ignored probably because the compiler was generating a default QJsonValueRef assignment operator Change-Id: I3a041595497308868dd7e4aab71027ce21bf8f0b Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Add default value for getters in QJsonValueLiang Qi2012-05-062-18/+44
| | | | | | | Done-with: Debao Zhang <dbzhang800@gmail.com> Change-Id: I3ddd8dd89dc75d91ac9977bf9b6eb3174d7669e4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Doc: Prepare for building modular QtCore docs.Casper van Donderen2012-04-193-42/+31
| | | | | | | | | | | | This change fixes most qdoc errors in QtCore. There are about 900 left. The main thing this change does is moving documentation from qtcore from /doc/src to /src/corelib/doc. Other issues resolved are mis-use of qdoc commands. Change-Id: I002d01edfb13575e8bf27ce91596a577a92562d1 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com> Reviewed-by: Jerome Pasion <jerome.pasion@nokia.com>
* Merge remote-tracking branch 'origin/master' into api_changesLars Knoll2012-04-164-6/+17
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure src/corelib/io/qurl.cpp src/gui/kernel/qwindow.cpp src/tools/moc/generator.cpp src/widgets/kernel/qwidget_qpa.cpp src/widgets/styles/qstyle.h src/widgets/widgets/qtabbar.cpp tests/auto/corelib/codecs/utf8/tst_utf8.cpp Change-Id: Ia457228d6f684ec8184e13e8fcc9d25857b1751e
| * replace hardcoded values with a surrogate handling methodsKonstantin Ritt2012-04-132-4/+5
| | | | | | | | | | | | Change-Id: Ib41e08d835f2e8ca2e32b4025c6f5a99840f2e27 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
| * fix QUtf8 codec to disallow codes in range [U+fdd0..U+fdef]Konstantin Ritt2012-04-112-2/+2
| | | | | | | | | | | | | | | | | | 0xfdef-0xfdd0 is definitely 31 and not 15 :) also fix all copy-pastes of this code (greping for '0xfdd0' helps ;) Change-Id: I8f3bd4fd9d85f9de066f0f5df378b9188c12bd48 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
| * Don't crash when comparing values containing empty arrays/objectsLars Knoll2012-04-112-0/+10
| | | | | | | | | | | | | | Task-number: QTBUG-25164 Change-Id: I1fa00e359ef3583b9a7136bb888cdf5e1c3e75ac Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com>
* | Merge remote-tracking branch 'origin/master' into api_changesOswald Buddenhagen2012-04-106-23/+105
|\| | | | | | | | | | | | | | | | | | | Conflicts: configure src/widgets/styles/qwindowsxpstyle.cpp tests/auto/gui/kernel/qwindow/qwindow.pro tests/auto/gui/kernel/qwindow/tst_qwindow.cpp Change-Id: I624b6d26abce9874c610c04954c1c45bc074bef3
| * Fix warnings about signed/unsigned comparisons in QtJson.Friedemann Kleint2012-04-032-5/+5
| | | | | | | | | | Change-Id: I92071ea870bf0ebb740fcb360aff19658380a0cd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Fix warnings about truncations in constants.Friedemann Kleint2012-04-031-1/+1
| | | | | | | | | | Change-Id: I46872c5b2866454112092c1ec5efbfe15db5af33 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Don't copy the whole binary input into QJsonDocumentDenis Dzyubenko2012-03-291-3/+4
| | | | | | | | | | | | | | | | | | If the input binary data exceeds the size of the enclosed binary object, we shouldn't allocate buffer and copy the whole content, but only content size that has meaningful data. Change-Id: I32587f504bd120c6e4e3d7e1b3403961a6f0d537 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
| * Validate size of the input in QJsonDocument::fromBinaryDataDenis Dzyubenko2012-03-291-2/+4
| | | | | | | | | | Change-Id: Ifc1d11b4dfbbe782d4e153118059c9affb833fa4 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
| * Properly detach when the modified object is a sub objectLars Knoll2012-03-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | The clone() method didn't detach if we had enough memory allocated, but didn't consider that the object being modified is not the root object of the binary blob. Change-Id: I9a479ae1c873b7fe9cff7e13c539e7a41961bf68 Reviewed-by: Cristiano di Flora <cristiano.di-flora@nokia.com> Reviewed-by: abcd <amos.choy@nokia.com> Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com>
| * QJsonParseError improvementsAlexei Rousskikh2012-03-272-11/+90
| | | | | | | | | | | | | | | | - added human-readable error message - improved enum value names Change-Id: I86d4bb419f9581f85d61b6e090048f1943017f9e Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* | Clean up constructors for "statics" in QString and QByteArrayJoão Abecasis2012-04-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There were two constuctors offering essentially the same functionality. One taking the QStatic*Data<N> struct, the other what essentially amounts to a pointer wrapper of that struct. The former was dropped and the latter untemplatized and kept, as that is the most generic and widely applicable. The template parameter in the wrapper was not very useful as it essentially duplicated information that already maintained in the struct, and there were no consistency checks to ensure they were in sync. In this case, using a wrapper is preferred over the use of naked pointers both as a way to make explicit the transfer of ownership as well as to avoid unintended conversions. By using the reference count (even if only by calling deref() in the destructor), QByteArray and QString must own their Data pointers. Const qualification was dropped from the member variable in these wrappers as it causes some compilers to emit warnings on the lack of constructors, and because it isn't needed there. To otherwise reduce noise, QStatic*Data<N> gained a member function to directly access the const_cast'ed naked pointer. This plays nicely with the above constructor. Its use also allows us to do further changes in the QStatic*Data structs with fewer changes in remaining code. The function has an assert on isStatic(), to ensure it is not inadvertently used with data that requires ref-count operations. With this change, the need for the private constructor taking a naked Q*Data pointer is obviated and that was dropped too. In updating QStringBuilder's QConcatenable specializations I noticed they were broken (using data, instead of data()), so a test was added to avoid this happening again in the future. An unnecessary ref-count increment in QByteArray::clear was also dropped. Change-Id: I9b92fbaae726ab9807837e83d0d19812bf7db5ab Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge master into api_changesKent Hansen2012-03-232-10/+19
|\| | | | | | | Change-Id: I93551e4d13a1b0815b359b9415060e9089477db1
| * Significantly speed up insertion into QJsonObject/ArrayLars Knoll2012-03-222-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | The code was only allocating memory for the next insertion leading to a reallocation of the whole data for every single insertion. The code now reserves some space and uses a decent growth strategy to avoid repeated reallocs. Change-Id: I48b0feab71ba8ca73e7037f8460080f198b2f009 Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com>
* | Merge master into api_changesKent Hansen2012-03-162-1/+9
|\| | | | | | | | | | | | | | | | | Conflicts: src/corelib/kernel/qmetatype.cpp src/gui/kernel/qplatformsurface_qpa.cpp tests/auto/corelib/tools/qtimeline/qtimeline.pro Change-Id: Iff3fff34eeeb06f02369767ddfce44cfde505178
| * Trailing comma should result in an error during JSON parsingAlexei Rousskikh2012-03-122-1/+9
| | | | | | | | | | | | | | | | | | 1. QJsonParseError::MissingObject defined 2. QJsonDocument::fromJson() will result in defined error after parsing of something like "{ 'key':1 , }" or "[ {'key':1}, ]" Change-Id: I8e6234a03b8aca4e5ad6180f273f91066b86d7a1 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* | Merge remote-tracking branch 'origin/master' into api_changesLars Knoll2012-03-122-2/+2
|\| | | | | | | | | | | | | Conflicts: tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp Change-Id: I884afc3b6d65c6411733a897a1949e19393573a7
| * Fix a bug in the assignment operators for QJsonObject and ArrayLars Knoll2012-03-082-2/+2
| | | | | | | | | | | | | | | | | | | | When objects or arrays where being used read only, several objects can share the same d pointer, but will have different pointers into the binary data. Correctly change the pointer into the binary data even if the d-pointer is the same. Change-Id: Ife0ea5ac5daf46586f855dccdf35b51ec696a623 Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
* | Merge remote-tracking branch 'origin/api_changes' into containtersJoão Abecasis2012-03-086-23/+27
|\| | | | | | | | | | | | | | | | | Conflicts: src/corelib/kernel/qmetaobject.cpp src/corelib/kernel/qvariant.cpp src/tools/moc/moc.h Change-Id: I2cd3d95b41d2636738c6b98064864941e3b0b4e6
| * Fix parsing of unicode escape sequencesLars Knoll2012-03-071-2/+2
| | | | | | | | | | Change-Id: I63a7cd3a571fb47c97157bcb2ca29c4239c600ba Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>