Extract from JSON processor

Edited

The Extract from JSON processor extracts the values wrapped in a JSON object in order to create new fields.

When to use this processor?

Your source data is located in a JSON format. When previewing your dataset, you see that instead of values, your fields contains data wrapped in curly brackets, meaning that the data is contained within JSON objects. You therefore need to extract the values contained in these JSON objects for them to surface properly.

How to fill it in

The processor is made up of two boxes only:

  • Field: A drop-down menu contains the titles of the different fields of the dataset. Select the field that contains the JSON object from which the values must be extracted.

  • Ijson rules: In this box, you will need to write down an iJSON rule to indicate the path to the values to extract. How to build it? An iJSON rule is built with the names of all the fields from the JSON root to the data to extract, separated with a dot. Let's see with some examples.

An example

{ "name": "Joe",
  "features" : {
        "hair" : "blond",
        "eyes": "brown",
        "genre": "male",
        "married": false
      },
  "contact" : { "email" : "joe.joe@gmail.com"}
}

We need to build a dataset from this JSON file. We need to have the following fields: name, hair, eyes, genre, married, and email. Use the processor Extract from JSON:

  • To extract the value Joe in a new field called "name", write the iJSON rule name

  • To extract the value blond in a new field called "hair", use the iJSON rule features.hair

  • To extract the value brown in a new field called "eyes", use the iJSON rule: features.eyes

  • To extract the value joe.joe@gmail.com use this rule: contact.email

  • If you use the rule features, you will get the following dataset schema. But, you will not get the values that are listed in the higher hierarchy of object (name, contact).

{
    "hair" : "blond",
    "eyes": "brown",
    "genre": "male"
}

Academy tutorial

This micro-course in Academy walks you through publishing JSON data on your portal.