Documentation menu

Mapping object for JSON

The mapping object for JSON is specified as the first element of the JSON array. This object is used for setting data types, creating multilevel hierarchies, and changing captions.

Properties

NameTypeDescription
typeStringoptional The field’s data type. Possible values: 
  • "number"
  • "string"
  • "date"
  • "date string"
  • "year/month/day"
  • "year/quarter/month/day"
  • "datetime"
  • "time"
  • "month"
  • "weekday"
  • "level"
  • "hidden"
 Read more about available data types in JSON.
captionStringoptional The field’s caption.
hierarchyStringoptional The name of the hierarchy. Used for multilevel hierarchies. Set this property to make the field a level of the specified hierarchy. In this case, the type must be set to "level"
parentStringoptional The caption of the parent hierarchy level. Used for multilevel hierarchies. In this case, the type must be set to "level"
levelStringoptional The caption of the hierarchy level. Used for multilevel hierarchies. In this case, the type must be set to "level".

Examples

1) Setting the mapping object in a JSON array of objects:

let jsonData = [
  {
    "Product": {
      type: "string"
    },
    "Price": {
      type: "number"
    }
  },
  {
    "Product": "Apple",
    "Price": 2.50
  },
  {
    "Product": "Cherry",
    "Price": 5.25
  }
];

See the full example on CodePen.

2) Setting the mapping object in a JSON array of arrays:

let jsonData = [
  {
    "Product": {
      type: "string"
    },
    "Price": {
      type: "number"
    },
  },
  ["Apple", 2.50],
  ["Cherry", 5.25]
];

Try a live demo on CodePen.

See also