#

# JSON Formats

Data for HTCondor View is provided in JSON or JSONP format.

The data is a series of records, each with one or more named fields.

The data must be a single array, either of objects or nested array. An array of objects has one property for each value, with the name of the property being the field name. A nested array begins with an array of field names, then has one array for each record, with the values matching the field names with the same index.

Given the data set

Color | Shape | Count
--- | --- | ---
red | sphere | 14
blue | cube | 6

It could be represented as

    [
    {
      "Color": "red",
      "Shape": "sphere",
      "Count": 14,
    },
    {
      "Color": "blue",
      "Shape": "cube",
      "Count": 6,
    }
    ]

or

    [
      [ "Color", "Shape", "Count"],
      [ "red",   "sphere", 14],
      [ "blue",  "cube",   6]
    ]

In JSON format, the framing "[" "]" are optional. In JSON format, an extra comma at the end is also allowed, but in that case the framing "[" "]" must be omitted. This may be useful for files where additional records are regularly appended, eliminating the need to keep moving the "]" and allowing every record to end with a comma. For example, the first example could be written as:

    {
      "Color": "red",
      "Shape": "sphere",
      "Count": 14,
    },
    {
      "Color": "blue",
      "Shape": "cube",
      "Count": 6,
    },

The JSONP is the same as the JSON format with a wrapper function. The function must be "jsonp". The first 6 characters must be exactly "jsonp(" and the last two ");". The contents must be strictly valid JSON; the framing "[" "]" must be present and there must not be a comma after the last record.

This is the first JSON example modified to be JSONP:

    jsonp([
    {
      "Color": "red",
      "Shape": "sphere",
      "Count": 14,
    },
    {
      "Color": "blue",
      "Shape": "cube",
      "Count": 6,
    }
    ]);

Values can be strings, numbers, dates, time/date pairs, or boolean values. The system attempts to deduce the correct type for a given field by examining values. Numbers can be placed in quotes; they will be interpreted as numbers if all values for that field can be. Dates can be in a variety of formats, including:

Format | Example
--- | ---
"YYYY-MM-DDThh:mm:ss.mmm" | "2015-12-31T23:59:59.999"
"YYYY-MM-DDThh:mm:ss" | "2015-12-31T23:59:59"
"YYYY-MM-DDThh:mm" | "2015-12-31T23:59"
"YYYY-MM-DD hh:mm" | "2015-12-31 23:59"
"YYYY-MM-DD" | "2015-12-31"
"Date(YYYY,MM,DD)" | "Date(2015,12,31)"
"Date(YYYY,MM,DD,hh,mm,ss)" | "Date(2015,12,31,23,59,59)"

Years must always be four digits.