Skip to main content

Supported JSON Table Formats

Overview

The JSON Card has an option to autodetect table formats and display a table directly instead of having to manually build it with a Select Card, below are all formats that instadeq will detect as tables.

Array of Objects

Example:

[
  {
    "Country": "United States",
    "Code": "US",
    "City": "New York",
    "Year": 2021,
    "Quarter": "Q4",
    "Line": "Watches",
    "Amount": 539.89
  },
  {
    "Country": "Portugal",
    "Code": "PT",
    "City": "Lisbon",
    "Year": 2021,
    "Quarter": "Q2",
    "Line": "VR",
    "Amount": 484.47
  }
]

Object with Column and Row Keys

The root value is an object, it has at least two keys, one for the columns and one for the rows, see valid names below.

The value for the columns key is an array of strings.

The value for the rows key is an array of arrays of scalars (number, string, bool, null).

Valid names for rows key:

  • r

  • rows

  • items

Valid names for columns key:

  • c

  • cols

  • columns

  • labels

Example:

{
  "columns": ["Country", "Code", "City", "Year", "Quarter", "Line", "Amount"],
  "rows": [
    ["United States", "US", "New York", 2021, "Q2", "VR", 425.6],
    ["Portugal",      "PT", "Lisbon",   2021, "Q1", "VR", 562.33]
  ]
}

Object with Columns as Keys

The root value is an object, each key is the name of a column and its value is an array of values for each row of that key, all values must be scalars (number, string, bool, null).

Example:

{
  "Country": ["United States", "Portugal"],
  "Code":    ["US",            "PT"],
  "City":    ["New York",      "Lisbon"],
  "Year":    [2021,            2021],
  "Quarter": ["Q2",            "Q1"],
  "Line":    ["Phones",        "VR"],
  "Amount":  [384.94,          199.85]
}

Array of Arrays with Headers as first Row

The root value is an array, each item in the array is an array, the first one is an array of strings containing the names of the columns, the remaining ones are the rows in the table and must be scalars (number, string, bool, null).

This case is selected when the first array item is an array and all of its values are strings.

Example:

[
  ["Country",       "Code", "City",     "Year", "Quarter", "Line",    "Amount"],
  ["United States", "US",   "New York", 2020,   "Q1",      "Tablets", 287.83],
  ["Portugal",      "PT",    "Lisbon",  2020,   "Q4",      "VR",      294.41]
]

Array of Arrays without Headers

The root value is an array, each item in the array is an array the items are the rows in the table and must be scalars (number, string, bool, null).

This case is selected when the first array item is an array but not all of its values are strings.

There's a corner case where the table columns are all strings but the first one is not the column names, we may introduce an extra option in the future to force this case over the previous one.

Example:

[
  ["United States", "US", "New York", 2020, "Q1", "Tablets", 287.83],
  ["Portugal",      "PT", "Lisbon",   2020, "Q4", "VR",      294.41]
]

Array of Columns as Pairs

The root value is an array, each item in the array with two items, the first one is a string representing the column name, the second is an array of values for each row of that key, all values must be scalars (number, string, bool, null).

Example:

[
  ["Country", ["United States", "Portugal"]],
  ["Code",    ["US",            "PT"]],
  ["City",    ["New York",      "Lisbon"]],
  ["Year",    [2020,            2021]],
  ["Quarter", ["Q3",            "Q3"]],
  ["Line",    ["Phones",        "Watches"]],
  ["Amount",  [175.96,          365.88]]
]