Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
join two json objects with jq
➜ 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