Reputation: 13
I have a question about transforming a json to jsonArray by jolt spec in apache nifi, my input is :
{
"name": "tom",
"experience ": [
{
"year": "2020",
"corp": "aaaa"
},
{
"year": "2019",
"corp": "bbbb"
}
]
}
and the output I need is :
[
{
"name": "tom",
"year": "2020",
"corp": "aaaa"
},
{
"name": "tom",
"year": "2019",
"corp": "bbbb"
}
]
can anyone help me ?
Upvotes: 1
Views: 309
Reputation: 12093
This should work:
[
{
"operation": "shift",
"spec": {
"experience": {
"*": {
"@(2,name)": "[#2].name",
"*": "[#2].&"
}
}
}
}
]
Note that you have a space in the field experience
, I removed it from the spec (and the sample input) when testing on the online Jolt tester.
Upvotes: 1