Json array transformation using jolt

504 views Asked by At

i want to transform a JSON array,

JSON:

{
    "data1": {
        "data2": [
            {
                "element1": "value1",
                "entity": [
                    "array0",
                    {
                        "element2": [
                            "abc",
                            "pqr",
                            "xyz"

                        ]
                    }
                ]
            }

desired output:

"data2" : {
                    "element1":"value1",
                    "entity" : "array0",
                    "element2":[abc,pqr,xyz]
            }

Please find find way to transform this JSON i have tried with different approach to access the element1 . its not working

1

There are 1 answers

0
Milo S On

Spec [ { "operation": "shift", "spec": { "data1": { "data2": { "*": { // data2 array index "element1": "data2[&1].element1", "entity": { // index input entity array explicilty with "0" and "1" "0": "data2[&2].entity", "1": { "element2": "data2[&3].element2" } } } } } } } ]