purplewind
purplewind

Reputation: 351

Is it possible to concatenate the values of JSON attributes using JOLT?

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?

Upvotes: 5

Views: 11116

Answers (2)

mido
mido

Reputation: 25054

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))"
    }
  }
]

Upvotes: 4

Milo S
Milo S

Reputation: 4586

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

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

Upvotes: 4

Related Questions