Supported JSON formats
In this guide, you can learn how to format your JSON data so WebDataRocks can process it.
JSON formats
WebDataRocks supports two JSON formats:
1) Array of objects. Each object is an unordered collection of key-value pairs, where the key is a field name and the value is a field member. Example:
[ { "Product": "Apple", "Price": 2.50 }, { "Product": "Cherry", "Price": 5.25 } ]
2) Array of arrays. The first subarray contains field names, while the other subarrays contain the respective field members. The field’s name and members must have the same position in the subarrays. Example:
[ ["Product", "Price"], ["Apple", 2.50], ["Cherry", 5.25] ]
Regardless of what JSON format you choose, the first element of each array can be the metadata object for JSON. This object is used to set data types and create multilevel hierarchies.
Input value formats
Number field format
Number values can contain digits, -
, and +
characters. Point .
must be used as a decimal separator. Numbers in exponential notation are also supported. Examples of valid values: -20
, 2.50
, 1.0E+2
.
String field format
String values must be enclosed in double quotation marks. Special characters, such as line breaks or double quotation marks, must be escaped using the backslash. Examples of valid values: "Apple"
, "\"A-Z\" section"
.
Date field format
Date fields must be defined in one of the following formats:
- ISO 8601. Examples:
"2018-01-10"
(date),"2018-01-10T08:14:00"
(date and time),"2018-01-10T06:14:00Z"
(date and time in UTC). - Unix timestamps in milliseconds. Examples:
1515535200000
(timestamp of the"2018-01-10"
date),1515564860000
(timestamp of the"2018-01-10 08:14:20"
date and time).
Note. By default, Unix timestamps are interpreted in WebDataRocks as numbers. To use them as dates, explicitly set the type property in the metadata object to the needed date type. - JavaScript Date objects. Can be used only with inline JSON data. Examples:
new Date(2018, 0, 10)
(creates the"2018-01-10"
date),new Date("January 10, 2018 08:14:20")
(creates"2018-01-10 08:14:20"
date and time).
Note. In the array of arrays, JavaScript Date objects are interpreted in WebDataRocks as strings. To use them as dates, explicitly set the type property in the metadata object to the needed date type.
Time field format
Time values must be specified as a number of seconds. The component displays values in the "HH:mm:ss"
format. Example: 5400
(displayed as "01:30:00"
).
To ensure the detection of time values, set the field type to "time"
in the metadata object. Otherwise, they will be processed as numbers.
Month field format
Month values must start with a capital letter. Full names and 3-letter abbreviations of months are supported. Examples: "October"
, "Dec"
, "May"
.
To ensure the detection of month values, set the field type to "month"
in the metadata object. Otherwise, they will be processed as strings.
Weekday field format
Weekday values must start with a capital letter. Full names and 3-letter abbreviations of the days of the week are supported. Examples: "Monday"
, "Sun"
, "Friday"
.
To ensure the detection of weekday values, set the field type to "weekday"
in the metadata object. Otherwise, they will be processed as strings.