The JSON-stat format is a simple lightweight JSON format for data dissemination. It is based in a cube model that arises from the evidence that the most common form of data dissemination is the tabular form. In this cube model, datasets are organized in dimensions. Dimensions are organized in categories.
The JSON-stat tree
Datasets are organized in dimensions and data.
Collections are sets of items. Items can be collections, datasets and dimensions (currently not supported by JJT).
Generally, items in a collection contain just basic content and a pointer that allow a client to retrieve the full information about the item. But a collection can also contain the full information (embedded items).
Bundles were packages of unordered arbitrary datasets.
Even though JSON-stat currently encourages the use of collections of embedded datasets instead of bundles, JJT supports both approaches.
The class of the response can be checked using the class property:
- label: label of the selected element (string)
- length: number of children of the selected element (number).
- id: IDs of the children of the selected element (array).
Reading and traversing methods
These methods (except JSONstat, which is not actually a method) accept a selection argument. If it is not provided, an array is returned with the information for every child of the selected element.
It reads a JSON-stat response and returns an object.
length//number of datasets in the objectlength//number of items in oecd-canada-col.json. Sync connection. (Not available in the Node.js module.)//number of items in oecd-canada-col.json. Async connection. (Not available in the Node.js module.)
It selects an embedded dataset in the JSON-stat collection (or bundle).
id //IDs of the dimensions in the first dataset
It selects a particular dimension in a dataset.
label//Label of the "time" dimension in the first datasetrole//Role of the "country" dimension in the first dataset
It selects a particular category in a dimension in a dataset.
label//Label of the first category of the "time" dimension in the first dataset
When an argument is passed, selects a single cell of the data cube in the JSON-stat response. If no argument is passed, returns all the cells.
The resulting object contains the property "value" (value of a cell) and "status" (its status).
value//Value of the first cell (usually a number, but values can be of any type).value//Value of the first cell in a dataset with 3 dimensions (usually a number).value//Unemployment rate in Greece in 2014 (usually a number).status//Status of unemployment rate in Greece in 2014.
When the argument is neither an integer nor an array, single category dimensions (“constant dimensions”) can be skipped. If one and only one non-constant dimension is not specified, the result will be an array with as many elements as categories in the unspecified dimension.
Transformation methods get information in the JSON-stat tree and export it to a different JSON structure for convenience.
This is a dataset method. It converts the information of a particular dataset into a JSON table. The conversion can be setup using an optional argument.
//Returns an array of arrays that exposes a tabular structure (rows and columns).//Useful in many situations. For example, it can be a Google Visualization API input.//Uses ids instead of labels as column names.//Returns an object of arrays (of objects) that exposes a tabular structure (rows and columns)//in the Google DataTable format (it's the native input format of Google//Visualization API input). The "vlabel" property is instructing the method to use//"Valor" as the label of the values column (instead of "Value").//The table will include a status column with label "Metadata".//Returns an array of objects where each dimension id is a property, plus a "value" property.//same but category ids ("AU") are used instead of labels ("Australia") even for content.//Get only the female population by age of Canada//and convert values from thousands to persons.