I'm working on implementing translations in my app, however the format of my translations is not usable for me. I made a shell script that uses jq to try to modify this array, but I cannot get the output that I desire.
The JSON I get from my service looks something like this.
{
"result": {
"terms": [
{
"term": "title",
"translation": {
"content": "Welcome to {{user}}"
}
},
{
"term": "car",
"translation": {
"content": {
"one": "car",
"other": "cars"
}
}
}
]
}
}
The output that I want is something like this.
{
"title": "Welcome to {{user}}",
"car_one": "car",
"car_other": "cars",
}
I've managed to strip away the uneeded parts of my objects, but I can't figure out how to append something to they key, e.g. turning "car" into "car_one". Or actually just adding the keys properly to the array.
This is currently where I'm at https://jqplay.org/s/P6KIEVX5sWp