5

I am wondering if there is any way to concatenate the values of JSON attributes into one new attribute using JOLT transformation.

For example, I have the following JSON:

{
  "name": "Mary",
  "Year Joined": "2017",
  "Gender": "Female"
}

and I would like it to be transformed into this:

{
  "new": "Mary_2017_Female"
}

Is it possible to do this using JOLT or are there other alternative ways to do it?

mido
  • 24,198
  • 15
  • 92
  • 117
purplewind
  • 331
  • 10
  • 26

2 Answers2

4

Yes, but it uses a "beta" transform that may change in the future.

http://jolt-demo.appspot.com/#modify-stringConcat

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

Expanding @Milo answer (not a fan of links outside SO)

Yes, you can achieve this using modify-overwrite-beta transform

The specification for your example would look like:

[
  {
     "operation": "modify-overwrite-beta",
    "spec": {
       "new": "=concat(@(1,name),'_',@(1,Year Joined),'_',@(1,Gender))"
    }
  }
]
mido
  • 24,198
  • 15
  • 92
  • 117