You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/routes/wiki/info/json/+page.svx
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: "A rough guide to the JSON format used in Minecraft Datapacks (amon
4
4
---
5
5
6
6
# JSON Format
7
-
JSON is a data storage type used by Minecraft Datapacks for files such as [predicates](/wiki/files/predicates) and [tags](/wiki/files/tags), as well as in [JSON Text](/wiki/concepts/json-text). JSON is a way of storing data, usually used in `.json` files but is also seen in `.mcmeta` files too.
7
+
JSON is a data storage type used by Minecraft Datapacks for files such as [predicates](/wiki/files/predicates) and [tags](/wiki/files/tags), as well as in [JSON Text](/wiki/concepts/text). JSON is a way of storing data, usually used in `.json` files but is also seen in `.mcmeta` files too.
8
8
9
9
## How JSON works
10
10
JSON stands for **JavaScript Object Notation**. It was originally created as a way of writing objects in Javascript. These days, JSON is used in almost every programming environment, datapacks included.
**Short**, **Int**, and **Long** data types all represent integers (whole numbers).
101
101
102
-
- **Byte** is an unsigned 8 bit integers, it can be any value from `0` to `255`
103
-
- **Short** is a signed 16 bit integer, it can be any value from `-32,768` to `32,767`
104
-
- **Int** is a signed 32 bit integer, it can be any value from `-2,147,483,648` to `2,147,483,647`
105
-
- **Long** is a signed 64 bit integer, it can be any value from `-9,223,372,036,854,775,808` to
102
+
- **Byte** is an 8 bit integer, it can be any value from `0` to `255`
103
+
- **Short** is a 16 bit integer, it can be any value from `-32,768` to `32,767`
104
+
- **Int** is a 32 bit integer, it can be any value from `-2,147,483,648` to `2,147,483,647`
105
+
- **Long** is a 64 bit integer, it can be any value from `-9,223,372,036,854,775,808` to
106
106
`9,223,372,036,854,775,807`
107
107
108
-
**Format**: By default, numbers are stored as integers. To store a number in the other formats, you need to use the appropriate suffix.
109
-
For shorts, ints, and longs, the prefix is `s`, `i`, and `l` respectively.
108
+
**Format**: By default, numbers are stored as integers. To store a number in the other formats, you need to use the appropriate suffix. For shorts, ints, and longs, the prefix is `s`, `i`, and `l` respectively.
109
+
110
+
The suffix can be extended with `u` or `s` to say whether it is unsigned (only a positive number) or signed (can be positive or negative) - for example, `402ub`.
111
+
112
+
It is also possible to write using E notation (e.g `1.2E3` would be `1200`), hexadecimals (e.g `0xBC` would be `188`), and binary (e.g `0b110` would be `6`)
@@ -125,23 +128,16 @@ appropriate suffix. For floats, the suffix is `f`. For doubles, the suffix is `d
125
128
126
129
### Bytes or Booleans
127
130
128
-
In older versions of Minecraft, booleans were stored as bytes with `0b` representing
129
-
`false` and `1b` representing `true`. In newer versions, booleans were introduced.
130
-
Essentially, booleans represent the old `0b` and `1b` with a more descriptive name.
131
-
It's recommended to use booleans instead of bytes whenever possible, as they are more readable.
131
+
In older versions of Minecraft, booleans were stored as bytes with `0b` representing `false` and `1b` representing `true`. In newer versions, booleans were introduced. Essentially, booleans represent the old `0b` and `1b` with a more descriptive name. It's recommended to use booleans instead of bytes whenever possible, as they are more readable.
132
132
133
-
### Arrays
134
133
135
-
Arrays are used to store multiple values of the same type. There are currently 3 types of arrays:
136
134
137
-
- **Byte Array**: Used to store multiple bytes
138
-
- **Int Array**: Used to store multiple integers
139
-
- **Long Array**: Used to store multiple longs
135
+
### Lists/Arrays
136
+
Lists, or number arrays are used to store multiple values. Lists can store different types of values, whereas number arrays can only store the same type of number. In practicality, you often do not need to think about the difference
140
137
141
-
**Format**: Arrays are defined using square brackets (`[]`), followed by the type of the array, a semicolon, and then your data.
142
-
The data still has to have prefixes if it needs it.
138
+
**Format**: Theyu are defined using square brackets (`[]`), with the values separated by commas. Number arrays can be prefixed with the type of numbr the array is going to store and a semicolon (for instance, a list starting with `[B;` will only store bytes)
0 commit comments