All schemas in the Q&B system are created using the JSON language. JSON is derived from the JavaScript programming language and uses the .json extension.
In this chapter we will discuss about what the JSON schema structure looks like and some syntax rules.
The following rules are applied to the JSON syntax:
"key": "value""key1": "value1", "key2": "value2", "key3": "value3"{} should hold objects[] hold arraysImportant data types used in JSON:
| Data Type | Description |
| Number | Integer or a rational number. |
| String | Any text. |
| Boolean | True or False values. |
| Null | The associated variable does not have any value. |
| Object | Collection of key-value pairs, always separated by a comma and enclosed in curly brackets. |
| Array | Ordered sequence of separated values enclosed in square brackets. |
Each of the data types that are passed in as values into JSON will maintain their own syntax, so strings will be in quotes, but numbers and booleans will not be.
All values of keys such as uiTypes, uiOptions, uiRules and also nested objects of properties must be written in the lower camel case. This means that if a variable consists of compound words, then the first word starts with a lowercase letter, the following words with an uppercase letter, and there is no whitespace between them:
multipleSectiononChangeshowByValueA JSON object is a key-value data format that is typically rendered in curly braces. In the Q&B system the JSON object usually defines the quote sections and fields in it.
Writing the JSON format on multiple lines often makes it much more readable, especially when dealing with a large data set.
Example of an object, written in one string: { "type": "object", "uiType": "section", "label": "Quote details", "description": "General quote information" }
As we can see, this line is barely readable. Luckily, JSON ignores whitespace, so we can write the same code in multiple lines:
{
"type": "object",
"uiType": "section",
"label": "Quote details",
"description": "General quote information"
}
Previous example was only a one level schema. This section will demonstrate nested data structure.
JSON can store nested objects in JSON format in addition to nested arrays. These objects and arrays will be passed as values assigned to keys, and typically will consist of of key-value pairs as well. Basically, a nested structure is when there is an object in another object (or array).
Example of a nested object:
{
"type": "object",
"uiType": "section",
"label": "Quote details",
"description": "General quote information",
"properties": {
"insuranceType": {
"label": "Insurance Type",
"default": "Direct",
"uiType": "select",
"options": [
"Direct",
"Reinsurance"
],
"uiOptions": {
"class": "col-3"
}
},
"businessClass": {
"label": "Business Class",
"uiType": "select",
"options": [
"Rotor Wing",
"Fixed Wing"
],
"default": "Fixed Wing",
"uiOptions": {
"class": "col-3"
}
}
}
}
In this example we saw all four syntax rules: data is in key name/value pairs, it is separated by commas, objects are stored in curly brackets, and arrays in square brackets. For more information what each keyword means, see Keywords.