I would like to use jq to turn an array of objects into an object of arrays.
Consider if I have the following two files:
file1.json:
{
"key1": 5,
"key2": 10
}
file2.json:
{
"key1": 2
}
I would like to merge them together to form:
{
"key1": [5, 2]
"key2": [10, null]
}
It's easy to do this with one field per jq command, but I can't figure out how to do it with all the fields at once. My thought is that I need to convert all the values to arrays and then use reduce with *, but I couldn't get it to work.
The jq command needs to work for an arbitrary number of files (more than 2).