JSON: a text format for data

Concepts explained

JSON stands for JavaScript Object Notation. It is a way to write structured data as text so different programs can exchange it. You do not need to learn JavaScript to read a small JSON document.

Read a player card

This is JSON data, not a Pliro program:

{"name": "Mila", "score": 12, "badges": ["starter"], "ready": true}

The braces group named values. "score" is a key and 12 is its value. The square brackets contain a list. JSON calls the brace-shaped group an object and the list an array.

JSON has text, numbers, true/false values, arrays, objects, and null for no value. Keys use double-quoted text. JSON does not allow comments or trailing commas. These rules come from the JSON standard.

In Pliro storage

A Pliro map looks similar but follows Pliro’s own rules. Pliro uses none where JSON uses null; Dutch Pliro uses geen, waar, and onwaar. JSON’s words stay unchanged in Dutch.

Pliro’s saved-data functions accept JSON-compatible values. That means values that can be represented using these data kinds. Functions cannot be saved as JSON. The storage layer handles the conversion; you pass ordinary Pliro values to saveData.

You do not need to assemble JSON strings to save a score. Read saving data for the supported calls and limits. This article does not introduce a JSON parsing built-in.

Try reading the card aloud: what is the value of ready, and how many badges are listed?