The problem:
I have N numbers of arrays of objects with the same identifying key within objects, and I'd love to merge those with jq.
This is a contrived example that attempts to illustrate the problem:
From
[
{
"google.com": {
"http": {
"dest_url": "http://stackoverflow.com"
}
}
},
{
"google.com": {
"https": {
"dest_url": "https://github.com"
}
}
},
{
"test.com": {
"https": {
"dest_url": "https://wikipedia.com"
}
}
}
]
To
{
"google.com": {
"http": {
"dest_url": "http://stackoverflow.com"
},
"https": {
"dest_url": "https://github.com"
}
},
"test.com": {
"https": {
"dest_url": "https://wikipedia.com"
}
}
}
I tried with jq '. | add' file but it ended up with the following result.
{
"google.com": {
"https": {
"dest_url": "https://github.com"
}
},
"test.com": {
"https": {
"dest_url": "https://wikipedia.com"
}
}
}