1

A little more sophisticated as my question mentioned below. I learned to use arrays more, but it screws things up too.

Input:

{ "a": [ { "b": "c", "d": "e" }, { "b": "f", "d": "g" } ], "h": [ { "b": "c", "i": "j" }, { "b": "f", "i": "k" } ] } 

desired output:

{ "l": [ { "b": "c", "d": "e", "i": "j" }, { "b": "f", "d": "g", "i": "k" } ] } 

Things that I've tried, based up on JQ How to merge multiple objects into one

{ x: [ inputs | .a[] | { (.h[]): .i } ] | add} 

1 Answer 1

1

The key to a simple solution is transpose:

[.a, .h] | transpose | map(add) | {l: .} 
Sign up to request clarification or add additional context in comments.

1 Comment

Tx for keeping count!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.