JSON (JavaScript Object Notation) is a lightweight data-interchange format. [1]
In Minecraft, JSON format is used to store the following data:
- Text in written books, signs, custom names and the
/tellraw,/title, and/bossbar[Java Edition only] commands. - The file
pack.mcmetathat describes a Java Edition resource pack and data pack[Java Edition only]. - The
manifest.jsonthat describes a Bedrock Edition add-on - Files in a resource pack that define models, sound events, and UI[Bedrock Edition only].
- Files in a behavior pack the define entity behaviors.
- Advancements and statistics (as
.minecraft/saves/*/data/stats/*.json) - The profile data for the Minecraft launcher (as
.minecraft/launcher_profiles.json) - Information about downloaded versions (as
.minecraft/versions/*/*.json) - Files in a data pack that define advancements, loot tables, and tags[Java Edition only].
Syntax
A JSON file must always contain opening and closing curly brackets which encapsulate all of the files data.
{
"string": "Hi",
"number": 1,
"object": {"stuff": "foobar", "digit": 13},
"array": ["spam", "foo"]
}
All element names in a JSON file must be contained inside quotes. To define a value, a colon is used after the name, followed by a value.
{
"name": "value"
}
All elements except for the last element in an array or object should have a comma after their value.
Data types
There are 5 different data types in regular JSON: string, number, object, array, and boolean.
String
A string is defined by single or double quotes and can contain any combination of characters or spaces except a backslash.
{
"foo": "bar",
"spam": "eggs"
}
Number
A number is defined by entering in any number.
{
"two": 2,
"one": 1,
"second": 1
}
Object
An object is defined by opening and closing curly brackets and can contain any combination of any data types. The required curly brackets at the beginning and end of a file make an object.
{
"Bob": {
"ID": 47182,
"lastName": "Ramsay"
},
"Alice": {
"ID": 47183,
"lastName": "Berg"
}
}
Array
Arrays are defined by
Boolean
A boolean is very simple; it can be true or false.
{
"Alice": {
"isMale": false
},
"Bob": {
"isMale": true
}
}