JSON

nFeed is able to process JSON content, either stored in local files or retrieved from an URL data source such as a REST API.

If you are manipulating complex JSON structures, nFeed allows you to use JSON Path to extract the subset of data you would like to use.


  • By default, attributes of the first object will be used as reference (one nFeed column per attribute) for every object in the list.
  • Value attributes (String, Number, Boolean, null) will be evaluated as their value. Other attributes (objects) are evaluated as the empty string.


Root element

In order to construct a table of data, we need an additional post processing step because JSON document does not fit directly into a table. 

JSON Path can be used to extract the subset of data you would like to use as a rows in a table of data.

See JSONPath explained for more details about JSONPath.

You can use velocity variables inside your JSON Path fields. Check out the list of accessible variables.

Example 1:

The following JSON file:

{
    "customers": [
        {
			"id": "CSTM-1",
            "name": "Matdax",
            "country" : "USA",
			"nb_employees": 250
        },
        {
			"id": "CSTM-2",
            "name": "ACME",
            "country" : "UK",
			"nb_employees": 75
        },    
        {
			"id": "CSTM-3",
			"name": "Global Corp",
            "country": "Australia",
			"nb_employees": 1230
        }
    ]
}

evaluated with the "$.customers" JSONPath in root element will result in the following data table:



Columns

If in order to get the needed data, user needs to further filter json root element or initial json document, for each needed data user can declare its name and the JSONPath that points to the data in the json document.

Example 2:

If we would only like to use "county" and "nb_employees" attributes for our nFeed field, in the Columns section we can declare:


This will result in the following data table:



Display templates

Once we built a table of data from our JSON document, we can choose which columns we would like to use in the display template.

See Display template for more details.