0

I am trying to perform conditional mapping of values from the following JSON.

My input,

   {
  "rating": [
    {
      "id": 1,
      "locations": [
        {
          "num": 1
        },
        {
          "num": 2
        }
      ]
    }
  ]
}

Expected output:

  {
  "rating": [
    {
      "id": 1,
      "locations": [
        {
          "num": 1
        }
      ],
      "new_locations": [
        {
          "num": 2
        }
      ]
    }
  ]
}

My spec,

  [
  {
    "operation": "shift",
    "spec": {
      "rating": {
        "*": {
          "locations": {
            "*": {
              "num": "@(3,id)"
            }
          }
        }
      }
    }
  }
]

If the num value matches with id,then it should stay in location array else should be moved to new_locations.

Can anyone please suggest me help.Thanks.

klp9
  • 1
  • 1

1 Answers1

0

There isn't a way to do that kind of conditional matching logic with the "out of the box" Jolt transforms.

Milo S
  • 4,466
  • 1
  • 19
  • 22