JSON
JSON stands for Javascript Object Notation. It's a way of representing data as text. We use it heavily in Report Builder 2 to define a bunch of things (instances, properties, data, calculation stages). JSON is widely documented online and I've included a few external tutorials at the bottom of this page. Here's my attempt to explain it briefly.
JSON consists mainly of Objects, Arrays, and primitives (string, number, boolean). Let's call these json tokens.
Object
An Object is defined with curly braces and contains a comma delimited set of properties in "key": value format. Property values can be any valid json token or null.
{
"productId": 101,
"productLabel": "Earbuds",
"ownershipVar": "Q13_101",
"somethingElse": null
}
Array
A JSON array is surrounded with square brackets and contains a comma delimited set of entries. Entries can can be any valid json token or null (here we use all strings).
[
"Alabama",
"Alaska",
"Arizona"
]
String
JSON strings are enclosed in quotation marks:
"This is a string"
If you need a quotation mark inside a string, you can escape it with a leading backslash \"
:
"This is a \"string\""
Number
20.4
Boolean
true
Null
null
A few examples
An array with Object elements:
[
{ "productId": 101, "productLabel": "Earbuds", "include": true },
{ "productId": 102, "productLabel": "Headphones" },
]
An object with various property value types, including Array:
{
"label": "Awareness",
"vars": ["q1_101", "q1_102", "q1_103"],
"index": 10,
"score": -45.2093,
"applyWeights": false
}
JSON5
JSON5 is a newer version of JSON that isn't fully adopted everywhere, but Report Builder uses it. It allows a few convenient things that you may notice within this documentation, such as comments, object properties without quotation marks, and trailing commas:
{
// this is a comment
label: "hi there", // unquoted property name and trailing comma
}
JSON5 allows a few more things you can read about here.
Learn more
Learn JSON in 10 Minutes on YouTube.
W3 Schools explains JSON in a tutorial format.
Here's the JSON grammar.
New features in JSON5 since RB uses it.