I tried Simple Jolt transformation but its not working

I want to convert this data using jolt, I tried but it showing null as result

Input :

{
  "employer": [
    {
      "id": "98",
      "place_id": "7871",
      "name": "Iti-ha-cho"
    }
  ]
}

Expected Output :

{
  "id" : "98",
  "place_id" : "7871",
  "name" : "Iti-ha-cho"
}

Jolt Spec I tried but didnt work :

{
  "operation": "shift",
  "spec": {
    "employer": {
      "id": "[&1].&",
      "place_id": "place_id",
      "name": "name"
    }
  }
}

>Solution :

While the current issue is due to missing square bracket nesting the spec, you don’t need to specify those long stuff, just the following spec will suffice

[
  {
    "operation": "shift",
    "spec": {
      "employer": {
        "*": ""
      }
    }
  }
]

as you only want to extract the sub-content of the employer array.

Leave a Reply