2

I have two arrays and need to convert these arrays into a single object array using jolt.

Input

"Name": ["Test  Test", "Test2  Test"]
"email": ["[email protected]", "[email protected]"]

output

[{"Name":"Test  Test","email":"[email protected]"},{"Name":"Test2  Test","email":"[email protected]"}]

1 Answer 1

1

Description inline:

[
  {
    "operation": "shift",
    "spec": {
      // for every key
      "*": {
        // and every item in the array
        "*": {
          // create a structure <index of array> : key : value
          // This will therefore join the two because the indexes will be the same
          "@": "&.&2"
        }
      }
    }
  },
  {
    //Remove the index as key
    "operation": "shift",
    "spec": {
      "*": "[]"
    }
  }
]

I'd suggest running the first shift to get understanding of the description.

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.