Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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 8259}.
23
24 \section1 Overview
25
26 JSON is a format to store structured data. It has 6 basic data types:
27
28 \list
29 \li bool
30 \li double
31 \li string
32 \li array
33 \li object
34 \li null
35 \endlist
36
37 A value can have any of the above types. A boolean value is represented by the
38 strings true or false in JSON. JSON doesn't explicitly specify the valid range
39 for numbers, but the support in Qt is limited to the validity range and precision of
40 doubles. A string can be any valid unicode string. An array is a list of values, and an
41 object is a collection of key/value pairs. All keys in an object are strings, and
42 an object cannot contain any duplicate keys.
43
44 The text representation of JSON encloses arrays in square brackets ([ ... ]) and
45 objects in curly brackets ({ ... }). Entries in arrays and objects are separated by
46 commas. The separator between keys and values in an object is a colon (:).
47
48 A simple JSON document encoding a person, his/her age, address and phone numbers could
49 look like:
50
51 \code
52 {
53 "FirstName": "John",
54 "LastName": "Doe",
55 "Age": 43,
56 "Address": {
57 "Street": "Downing Street 10",
58 "City": "London",
59 "Country": "Great Britain"
60 },
61 "Phone numbers": [
62 "+44 1234567",
63 "+44 2345678"
64 ]
65 }
66 \endcode
67
68 The above example consists of an object with 5 key/value pairs. Two of the values are strings,
69 one is a number, one is another object and the last one an array.
70
71 A valid JSON document is either an array or an object, so a document always starts
72 with a square or curly bracket.
73
74 \sa {Saving and Loading a Game}
75
76 \section1 The JSON Classes
77
78 All JSON classes are value based,
79 \l{Implicit Sharing}{implicitly shared classes}.
80
81 JSON support in Qt consists of these classes:
82*/