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

2

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?

Susurrant answered 19/1, 2017 at 3:2 Comment(0)
T
4

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

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

Timeserver answered 20/1, 2017 at 16:17 Comment(0)
F
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))"
    }
  }
]
Flick answered 16/7, 2020 at 13:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.