Skip to content

Instantly share code, notes, and snippets.

@CodyKochmann
Created July 2, 2021 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodyKochmann/725752bc2ebfb42599b3fc5868845241 to your computer and use it in GitHub Desktop.
Save CodyKochmann/725752bc2ebfb42599b3fc5868845241 to your computer and use it in GitHub Desktop.
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