Created 10-21-2024 11:49 PM
Hi,
I am using JoltTransformJson to convert a plain json to nested json in Nifi and getting null in the output. The same i/p and spec is working in Jolt demo. Below are the input and the spec
Input:
{
"ts" : "2024-09-22T12:03:13.000Z",
"sourceDeviceId" : 4321,
"sourceName" : "light1",
"sourceType" : "light",
"locationLat" : 201.34,
"locationLon" : 101.5,
"locationId" : 1,
"recordDate" : "2024-09-22T12:03:13.000Z",
"_class" : "com.prutech.smartcity.entity.LightEntity",
"_id" : "66f27c487bd8652abecdb9c7",
"status" : "INACTIVE",
"power" : 0,
"current" : 0,
"intensity" : 100,
"voltage" : 0
}
Jolt Spec:
Please help.
Created 10-22-2024 07:59 AM
NiFi expects the Jolt specification to be provided as an array of objects if it's set chain. This is typical when using JoltTransformJSON because it supports multiple transformations chained together.
Also, if you click on your JoltTransformJSON and click on the advanced option -
It will bring up a nice Jolt Spec tester for you that is consistent with how NiFi will handle the transformation -
Solution is just wrapping it in an array.
[
{
"operation": "shift",
"spec": {
"ts": "ts",
"sourceDeviceId": "source.deviceId",
"sourceName": "source.name",
"sourceType": "source.type",
"locationLat": "location.lat",
"locationLon": "location.lon",
"locationId": "location.id",
"recordDate": "recordDate",
"_class": "_class",
"status": "status",
"power": "power",
"current": "current",
"intensity": "intensity",
"voltage": "voltage"
}
}
]
Please accept the solution!
Created 10-22-2024 07:59 AM
NiFi expects the Jolt specification to be provided as an array of objects if it's set chain. This is typical when using JoltTransformJSON because it supports multiple transformations chained together.
Also, if you click on your JoltTransformJSON and click on the advanced option -
It will bring up a nice Jolt Spec tester for you that is consistent with how NiFi will handle the transformation -
Solution is just wrapping it in an array.
[
{
"operation": "shift",
"spec": {
"ts": "ts",
"sourceDeviceId": "source.deviceId",
"sourceName": "source.name",
"sourceType": "source.type",
"locationLat": "location.lat",
"locationLon": "location.lon",
"locationId": "location.id",
"recordDate": "recordDate",
"_class": "_class",
"status": "status",
"power": "power",
"current": "current",
"intensity": "intensity",
"voltage": "voltage"
}
}
]
Please accept the solution!
Created 10-25-2024 10:01 AM
Has the reply helped resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future. Thanks.
Regards,
Diana Torres,