Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
json.qdoc
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \group json
6 \title JSON Support in Qt
7 \ingroup qt-basic-concepts
8 \brief An overview of JSON support in Qt.
9 \ingroup explanations-dataprocessingandio
10 \ingroup frameworks-technologies
11
12 \keyword JSON
13
14 Qt provides support for dealing with JSON data. JSON is a
15 format to encode object data derived from Javascript, but
16 now widely used as a data exchange format on the internet.
17
18 The JSON support in Qt provides an easy to use C++ API to parse,
19 modify and save JSON data.
20
21 More details about the JSON data format can be found at \l{http://json.org}{json.org}
22 and in \l {RFC 4627}.
23
24 \tableofcontents
25
26 \section1 Overview
27
28 JSON is a format to store structured data. It has 6 basic data types:
29
30 \list
31 \li bool
32 \li double
33 \li string
34 \li array
35 \li object
36 \li null
37 \endlist
38
39 A value can have any of the above types. A boolean value is represented by the
40 strings true or false in JSON. JSON doesn't explicitly specify the valid range
41 for numbers, but the support in Qt is limited to the validity range and precision of
42 doubles. A string can be any valid unicode string. An array is a list of values, and an
43 object is a collection of key/value pairs. All keys in an object are strings, and
44 an object cannot contain any duplicate keys.
45
46 The text representation of JSON encloses arrays in square brackets ([ ... ]) and
47 objects in curly brackets ({ ... }). Entries in arrays and objects are separated by
48 commas. The separator between keys and values in an object is a colon (:).
49
50 A simple JSON document encoding a person, his/her age, address and phone numbers could
51 look like:
52
53 \code
54 {
55 "FirstName": "John",
56 "LastName": "Doe",
57 "Age": 43,
58 "Address": {
59 "Street": "Downing Street 10",
60 "City": "London",
61 "Country": "Great Britain"
62 },
63 "Phone numbers": [
64 "+44 1234567",
65 "+44 2345678"
66 ]
67 }
68 \endcode
69
70 The above example consists of an object with 5 key/value pairs. Two of the values are strings,
71 one is a number, one is another object and the last one an array.
72
73 A valid JSON document is either an array or an object, so a document always starts
74 with a square or curly bracket.
75
76 \sa {Saving and Loading a Game}
77
78 \section1 The JSON Classes
79
80 All JSON classes are value based,
81 \l{Implicit Sharing}{implicitly shared classes}.
82
83 JSON support in Qt consists of these classes:
84*/