Jolt Transformation - Replace text on json

Viewed 697

I would like to replace all "test" if exists with "" string

{
  "ids": {
    "id1": "testT123",
    "id2": "test123asd",
    "id3": "1234"
  }
}

Desired Output:

{
  "ids" : {
    "id1" : "T123",
    "id2" : "123asd",
    "id3" : "1234"
  }
}

I am trying to use "operation": "modify-overwrite-beta" but not able to figure out how to modify a string

1 Answers

You can consecutively apply split and join functions along with modify-overwrite-beta spec such as

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "*": {
        "*": "=split('test',@(1,&))"
      }
    }
  },
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "*": {
        "*": "=join('',@(1,&))"
      }
    }
  }
]

enter image description here

Related