I need to define the structure of JSON for all my incoming flow files. I have a JSON which is like this,
[
{
"user": "Tony",
"dept": "Sales",
"os": "linux"
},
{
"user": "Smith",
"os": "Windows",
"dept": "Accounts"
}
]
I want all my files of JSON to have a uniform structure sorted, eg. in the input my field positions are different for first object and second object. In the input the order we see is
{ "user" , "dept" , "os" } , { "user", "os", "dept" }
I want my output to be
{ "user" , "dept" , "os" }, { "user" , "dept", "os" }
Need help doing this in Nifi
You can use a shift transformation spec by individually writing each attribute in order to sort them as desired such as
[
{
"operation": "shift",
"spec": {
"*": {
"user|dept|os": "[&1].&"
}
}
}
]
the demo on the site http://jolt-demo.appspot.com/ is