I need help with a JSON
transformation. I'm using NIFI
to transform a flat JSON
into a nested JSON
. I'm using processor JoltTransformJSON
in version 1.8.0
.
I have this JSON
:
[
{
"territoryName":"Bauru",
"territoryCode":"50",
"territoryLatitude":1,
"territoryLongitude":1,
"branchCode":"80",
"branchName":"Aracatuba",
"branchLatitude":1,
"branchLongitude":1
},
{
"territoryName":"Bauru",
"territoryCode":"50",
"territoryLatitude":1,
"territoryLongitude":1,
"branchCode":"50",
"branchName":"Bauru",
"branchLatitude":1,
"branchLongitude":1
},
{
"territoryName":"Bauru",
"territoryCode":"50",
"territoryLatitude":1,
"territoryLongitude":1,
"branchCode":"74",
"branchName":"Fernandopolis",
"branchLatitude":1,
"branchLongitude":1
}
]
And I need an output like this
{
"territoryName":"Bauru",
"territoryCode":"50",
"area":[
{
"latitude":1,
"longitude":1
},
{
"latitude":1,
"longitude":1
},
{
"latitude":1,
"longitude":1
}
],
"branches":[
{
"branchName":"Aracatuba",
"branchCode":"80",
"area":[
{
"latitude":1,
"longitude":1
},
{
"latitude":1,
"longitude":1
}
]
},
{
"branchName":"Bauru",
"branchCode":"50",
"area":[
{
"latitude":1,
"longitude":1
},
{
"latitude":1,
"longitude":1
}
]
},
{
"branchName":"Fernandopolis",
"branchCode":"74",
"area":[
{
"latitude":1,
"longitude":1
},
{
"latitude":1,
"longitude":1
}
]
}
]
}
I'm trying JOLT
on line but I can't figure out how to create the spec to do it. Any help is welcome.