Scripting: JSON – Arma Reforger

From Bohemia Interactive Community
Revision as of 00:06, 24 February 2023 by Lou Montana (talk | contribs) (Text replacement - "\{\{Wikipedia *\| *([a-zA-Z0-9_#]+) *\}\}" to "{{Link|https://en.wikipedia.org/wiki/$1}}")
Jump to navigation Jump to search

JSON Format

JSON stands for JavaScript Object Notation. It is a way to present data in a simple form.

See:

The parent class is always an object (the O from JSON).

{
}

A property is defined with its name on the left of the colon, and its value on the right. Properties and strings are defined by double-quotes ".
If another property follows, a comma is required. If no other property follows, there must be no comma.

There can be no comments in a JSON file.
{
	"property": 42
}
{
	"property1": 41,
	"property2": "fourty-two"
}

Spacing does not matter outside of the quotes.

{
	"property1": "name",
	"property2": 42
}

is identical to

{"property1":"name","property2":42}

but for obvious readability reasons, tabs and spaces are welcome.

Boolean

A boolean can be either true or false and nothing else.

{
	"boolean1": true,
	"boolean2": false
}

Number

A number can be either an integer or a float. There are no quotes around it. It cannot start with a period .. Scientific notations are accepted.

{
	"number1": 42,
	"number2": 4.2,
	"number3": -33,
	"number4": 10e10
}

String

Line returns cannot happen in JSON strings. The following character escape sequences are accepted:

{
	"string1": "This is a string",
	"string2": "Is \"this\" a string?\tYes, Sir\u0021"
}

Object

{
	"object1": {
		"property1": "sub-object"
	}
}

The null value is covered.

{
	"object1": null
}

Array

An array can contain anything: direct values, or other objects with named properties.

{
	"array1": [
		4,
		5,
		6
	],
	"array2": ["This", "is", "Sparta!"],
	"array3": [
		{
			"name": "object's name",
			"value": 33
		},
		{ "name": "another object, inlined", "value": 42 }
	]
}


See Also