JSON support in Qt QT5 begins with supporting the processing of JSON data, which is a data format for Interter data interchange. JSON is used to store structured data, and JSON has 6 basic data types:
bool |
Double |
String |
Array |
Object |
Null |
All keys is strings, and an object cannot contain any duplicate keys. In a JSON object, all keys are strings and cannot contain duplicate strings. Entries in arrays and objects is separated by commas. The separator between keys and values in an object are a colon (:). In JSON, keys and values are separated by ":", and multiple key-value pairs are separated by ",". A valid JSON document is either an array or an object, so a document always starts with a square or curly bracket. Valid JSON text This is an array or an object, so the JSON text always starts with brackets or curly braces.
Example:
{ "FirstName": "John", "LastName": "Doe", "Age": 43, "Address": { "Street": "Downing Street 10", "City": "London", "Country": "Great Britain" }, "Phone numbers": [ "+44 1234567", "+44 2345678" ] } |
JSON-related classes in QT
Qjsonarray |
Encapsulates a JSON array |
Encapsulating JSON arrays |
Qjsondocument |
The to read and write JSON documents |
How JSON text is read and written |
Qjsonobject |
Encapsulates a JSON object |
Encapsulating JSON objects |
Qjsonobject::iterator |
Qjsonobject::iterator class provides an stl-style Non-const iterator for Qjsonobject |
JSON iterator |
Qjsonobject::const_iterator |
Qjsonobject::const_iterator class provides a Stl-style const iterator for Qjsonobject |
JSON Const iterator |
Qjsonparseerror |
Used to report errors during JSON parsing |
Used to report errors during JSON parsing |
Qjsonvalue |
Encapsulates a value in JSON |
Encapsulates a value in JSON
|
http://blog.csdn.net/jan5_reyn/article/details/38955721
QT Translation: JSON support in QT (JSON has only six data types)