prathik vijaykumar
prathik vijaykumar

Reputation: 395

Extract particular fields from json array Nifi

I have the following input json, which has an array of json:

{
  "ArrayList": [
    {
      "a": "value1",
      "b": "value2",
      "c": "value3"
    },
    {
      "a": "value4",
      "b": "value5",
      "c": "value6"
    },
    {
      "a": "value7",
      "b": "value8",
      "c": "value9"
    }
  ]
}

And the desired output is :

{
  "ArrayList": [
    {
      "a": "value1",
      "b": "value2"
    },
    {
      "a": "value4",
      "b": "value5"
    },
    {
      "a": "value7",
      "b": "value8"
    }
  ]
}

What will be the Jolt transform spec expression for this?

Upvotes: 0

Views: 249

Answers (1)

Barbaros Özhan
Barbaros Özhan

Reputation: 65373

Seems you want to remove the attribute c of objects of the ArrayList array, then a remove transformation might be used such as

[
  {
    "operation": "remove",
    "spec": {
      "ArrayList": {
        "*": {
          "c": ""
        }
      }
    }
  }
]

Upvotes: 1

Related Questions