I have a translation management tool to which I upload a json file input.json. Next a translator does his/her translation job and the result is exported to a json file containing all the translations output.json. Both input.json and output.json contain the same keys but not the same values (these are the translations added/modified by the translator). More importantly the order of the keys in input.json and output.json is completely different. Functionally this does not matter but in pull requests the input.json is the "old" file that is compared to the "new" file being output.json. This generates a lot of diffs due to the changed order of the keys, mking reviews cumbersome. Is there an easy way to order output.json in the same way as input.json?
I found that jq could be used to order input.json "alphabetically" so then I could afterwards order output.json alphabetically as well and this would kind of solve my problem but isn't it possible to use jq do actually take the order of the keys in input.json and apply that to output.json?
Here is some demo data for input.json:
{
"BathroomType": "Type of bathroom",
"BuildingType": "Type of building",
"enums": {
"OrientationGarden": {
"EAST": "East",
"SOUTH": "South",
"NORTH": "North",
"WEST": "West"
},
"TerrainRecentDestination": {
"EXTRACTION": "extraction",
"PARK": "park"
}
}
}
and for output:
{
"BathroomType": "Type of bathroom2",
"enums": {
"TerrainRecentDestination": {
"EXTRACTION": "extraction",
"PARK": "park"
},
"OrientationGarden": {
"SOUTH": "South",
"EAST": "East2",
"NORTH": "North",
"WEST": "West"
}
},
"BuildingType": "Type of building"
}