This is input JSON which has array, which can contain one or more objects. inside the object lang is array. It will always have one object which is fix. I want to flatten it.
[
{
"name": "James",
"id": 1,
"lang": [
{
"primary": "python",
"secondary": "c++"
}
]
},
{
"name": "Kevin",
"id": 2,
"lang": [
{
"primary": "scala",
"secondary": "java"
}
]
}
]
I want to flatten the JSON like this - expected output
[
{
"name": "James",
"id": 1,
"primary": "python",
"secondary": "c++"
},
{
"name": "Kevin",
"id": 2,
"primary": "scala",
"secondary": "java"
}
]
Im tryin to build specification like this but its not working
[
{
"operation": "shift",
"spec": {
"*": {
"name": "[&1].name",
"id": "[&1].id",
"lang": {
"*": {
"primary": "lang\\[&2\\]\\.primary",
"secondary": "lang\\[&2\\]\\.secondary"
}
}
}
}
}
]

