Reputation: 71
I am new to NiFi, I have a requirement where i need the below JSON in below output format. I just want to remove one part completely from the json. Is it possible in Nifi. If possible which processor should i use.
Input :
{
"eventId": "123456",
"eventType": "Sample",
"eventTime": "2021-04-20",
"payload": {
"product": [
{
"status": "Published",
"level": "Test",
"productType": "Test",
"productClassification": "Test",
"productName": "Test",
"minQuantity": 1,
"chargeUnit": "USD",
"recurringFrequency": "Test",
"eligibility": {
"eligibleAccountCriteria": {
"isShared": false,
"eligibleAccounts": [
{
"accountId": 12345,
"accountName": "Test"
}
]
}
}
}
]
}
}
Output :
{
"eventId": "123456",
"eventType": "Sample",
"eventTime": "2021-04-20",
"payload": {
"product": [
{
"status": "Published",
"level": "Test",
"productType": "Test",
"productClassification": "Test",
"productName": "Test",
"minQuantity": 1,
"chargeUnit": "USD",
"recurringFrequency": "Test",
"eligibility": {
"eligibleAccountCriteria": {
"isShared": false,
"eligibleAccounts": []
}
}
}
]
}
}
Can anyone help me on this.
Upvotes: 0
Views: 297
Reputation: 2116
Use JoltTransformJSON with spec,
[
{
"operation": "remove",
"spec": {
"batters": {
"batter": ""
}
}
}
]
Edit 1 :
The below spec removes the objects in the array. In case of arrays index of the array needs to be tracked while traversing.
[
{
"operation": "remove",
"spec": {
"payload": {
"product": {
"*": {
"eligibility": {
"eligibleAccountCriteria": {
"eligibleAccounts": {
"*": ""
}
}
}
}
}
}
}
}
]
Upvotes: 2