Daniel
Daniel

Reputation: 31

JOLT: transform all json elements of type "array"

I would like to convert ALL arrays in a json via JOLT to a list of key-value pairs:

input:

"ex":{"arr": ["1", "2", "3", "4"]}

desired output:

"ex-arr-0": "1", 
"ex-arr-1": "2", ...

Upvotes: 0

Views: 1157

Answers (2)

Daniel
Daniel

Reputation: 31

i solved it via the following:

{
    "*": 
    {
        "ex": {"*": {"*": "&3.&2-&1-&"}}
    }
}

Upvotes: 0

Milo S
Milo S

Reputation: 4586

Spec

[
  {
    "operation": "shift",
    "spec": {
      "ex": {
        "arr": {
          "*": "ex-arr-&"
        }
      }
    }
  }
]

Upvotes: 1

Related Questions