Reputation: 73
I have two files containing json arrays like so
file1.json
[
{
"classid":"abc",
"name":"Alex"
},
{
"classid":"abc",
"name":"Bob"
}
]
file2.json
[
{
"classid":"abc",
"classname":"math"
}
]
I'd like to combine these two files on "classid". Desired output.json
[
{
"classid":"abc",
"name":"Alex",
"classname":"math
},
{
"classid":"abc",
"name":"Bob",
"classname":"math
}
]
I tried
> jq -s 'reduce .[] as $item ({}; . *= $item)' file1.json file2.json
but I see a jq: error (at file1.json:10): object ({}) and array ([{"classid...) cannot be multiplied
Would appreciate any help.
Upvotes: 0
Views: 414