I have two json files, each containing one simple object, for example:
file1
{
"key1": "value1",
"key2": "value2"
}
file2
{
"key1": "valueA",
"key3": "valueB"
}
I need to combine these two using jq so that I end up with one object that contains all of the keys from both objects. If there are common keys, I need the values of from second object being used.
I'm struggling to get the right expression to use. I thought that something as simple as
jq '. * .' file1 file2
should give me what I want, however this results in a non-json output:
{
"key1": "value1",
"key2": "value2"
}
{
"key1": "valueA",
"key3": "valueB"
}
The same exact thing happens if I use jq '. + .' file1 file2.
How can I combine these two objects?