1

I'm trying to join (comma separated) a nested array but cannot achieve it.

Input:

{
    "PARTS" : [ [ "aaaa", "bbbb" ], [ "cccc", "dddd" ] ]
}

Desired output:

{
    "PARTS": [ "aaaa,bbbb", "cccc,dddd" ]
}

I am trying to use =join but yet unsuccessful. Any help is appreciated.

Thanks!

1 Answer 1

1

I managed to get the output you were aiming for :)

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "PARTS": {
        "*": "=join(', ',@0)"
      }
    }
  }
]

The trick here is using @0, which points to the 0-th element on the hierarchy you're working with. At least, that's what the documentation says.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.