I have following JSON data . I want to transform following data by Jolt nifi processor into result data
{
"alert_array": {
"alerts": [
{
"alertId": "alt001",
"severity": "High",
"alert_type": "Alert"
},
{
"alertId": "alt002",
"severity": "High",
"alert_type": "Alert"
}
]
}
}
result data
{
"alert_array": [
{
"Id": "alt001",
"speed": "High",
"type": "Alert"
},
{
"Id": "alt002",
"speed": "High",
"type": "Alert"
}
]
}
please help to write spac of jolt transformation
If you wouldn't rename the attributes, then using
[
{
"operation": "shift",
"spec": {
"*": {
"*": {
"*": "&2[&]" // &2 represents going two levels up to get the literal "alert_array"
}
}
}
}
]
would suffice.
the demo on the site http://jolt-demo.appspot.com/ is
But in your case, you need to qualify each one individually such as
[
{
"operation": "shift",
"spec": {
"*": {
"*": {
"*": {
"alert*": "&3[&1].&(0,1)",
"severity": "&3[&1].speed",
"alert_*": "&3[&1].&(0,1)"
}
}
}
}
}
]
the demo on the site http://jolt-demo.appspot.com/ is
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.