join two json objects with jq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ tmp.QicwwydLd3 cat a.json | |
{ | |
"name": "Cody Kochmann", | |
"flags": [ | |
"engineer", | |
"scientist" | |
], | |
"stats": { | |
"commits": 45 | |
} | |
} | |
➜ tmp.QicwwydLd3 cat b.json | |
{ | |
"name": "Cody Kochmann", | |
"id": 38576254, | |
"flags": [ | |
"pilot", | |
"scientist" | |
], | |
"stats": { | |
"commits": 34, | |
"merges": 40 | |
} | |
} | |
➜ tmp.QicwwydLd3 jq -s '.[0] * .[1]' a.json b.json | |
{ | |
"name": "Cody Kochmann", | |
"flags": [ | |
"pilot", | |
"scientist" | |
], | |
"stats": { | |
"commits": 34, | |
"merges": 40 | |
}, | |
"id": 38576254 | |
} | |
➜ tmp.QicwwydLd3 jq -s '.[0] * .[1]' b.json a.json | |
{ | |
"name": "Cody Kochmann", | |
"id": 38576254, | |
"flags": [ | |
"engineer", | |
"scientist" | |
], | |
"stats": { | |
"commits": 45, | |
"merges": 40 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment