JSON files

JSON stands for "JavaScript Object Notation", which is a popular lightweight textual format that is used to store object-oriented data in a human-readable form. It comes from JavaScript where it is the native format used to store object information; however, it is commonly used across many programming languages and a popular format for web data exchange. Qt Core supports JSON format, as we'll see in the following code. A simple JSON-formatted definition looks as follows:

{
    "name": "Joe",
    "age": 14,
    "inventory": [
        { "type": "gold", "amount": "144000" },
        { "type": "short_sword", "material": "iron" }
    ]
} 

JSON objects can contain values of the following types:

Type Description
bool A boolean value (true or false).
double

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.