- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Filter and removing using jolt
- Labels:
-
Apache NiFi
Created ‎02-10-2025 03:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi i have json input like that:
{
"messageId": 1234,
"markerId": "T",
"dateFrom": 6436058131202690000,
"dateTo": -3840351829778683400,
"records": [
{
"recordId": 1,
"account": "152739203233"
},
{
"recordId": 2,
"data": {
"email": "jsmith@gmail.com",
"firstName": "John",
"lastName": "Smith"
}
},
{
"recordId": 3,
"city": "Los Angeles"
},
{
"recordId": 4,
"idNumber": "12345"
},
{
"recordId": 5,
"accountNumber": "55671"
},
{
"recordId": 6,
"account": "6789189790191"
},
{
"recordId": 7,
"city": "San Fransisco"
}
]
}
And I would like to have output like that:
[ {
"messageId" : 1234,
"markerId" : "T"
"dateFrom" : 6436058131202690000,
"dateTo" : -3840351829778683400,
"recordId" : 1,
"account": "152739203233"
}, {
"messageId" : 1234,
"markerId" : "T"
"dateFrom" : 6436058131202690000,
"dateTo" : -3840351829778683400,
"recordId" : 2,
"email": "jsmith@gmail.com",
"firstName": "John",
"lastName": "Smith"
}, {
"messageId" : 1234,
"markerId" : "T"
"dateFrom" : 6436058131202690000,
"dateTo" : -3840351829778683400,
"recordId" : 3,
"city": "Los Angeles"
}, {
"messageId" : 1234,
"markerId" : "T"
"dateFrom" : 6436058131202690000,
"dateTo" : -3840351829778683400,
"recordId" : 6,
"account": "6789189790191"
}, {
"messageId" : 1234,
"markerId" : "T"
"dateFrom" : 6436058131202690000,
"dateTo" : -3840351829778683400,
"recordId" : 7,
"city": "San Fransisco"
} ]
i need to have only this record with account, data(email,firstName,lastName) or city, i dont need records with idNumber and accountNumber. Additionally, I need each record to have a common part: messageId, markerId, dateFrom and dateTo Is it possible to do something like that with jolt transformation?
Created ‎02-10-2025 10:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi again,
I managed how to split records into individual records thanks to JOLT like this:
[
{
"operation": "shift",
"spec": {
"records": {
"*": {
"@(2,messageId)": "[&1].messageId",
"@(2,markerId)": "[&1].markerId",
"@(2,dateFrom)": "[&1].dateFrom",
"@(2,dateTo)": "[&1].dateTo",
"recordId": "[&1].recordId",
"account": "[&1].account",
"data": {
"email": "[&2].email",
"firstName": "[&2].firstName",
"lastName": "[&2].lastName"
},
"city": "[&1].city"
}
}
}
}
]
Now my output is like this:
[ {
"messageId" : 1234,
"markerId" : "T",
"dateFrom" : 6436058131202690000,
"dateTo" : -3840351829778683400,
"recordId" : 1,
"account" : "152739203233"
}, {
"messageId" : 1234,
"markerId" : "T",
"dateFrom" : 6436058131202690000,
"dateTo" : -3840351829778683400,
"recordId" : 2,
"email" : "jsmith@gmail.com",
"firstName" : "John",
"lastName" : "Smith"
}, {
"messageId" : 1234,
"markerId" : "T",
"dateFrom" : 6436058131202690000,
"dateTo" : -3840351829778683400,
"recordId" : 3,
"city" : "Los Angeles"
}, {
"messageId" : 1234,
"markerId" : "T",
"dateFrom" : 6436058131202690000,
"dateTo" : -3840351829778683400,
"recordId" : 4
}, {
"messageId" : 1234,
"markerId" : "T",
"dateFrom" : 6436058131202690000,
"dateTo" : -3840351829778683400,
"recordId" : 5
}, {
"messageId" : 1234,
"markerId" : "T",
"dateFrom" : 6436058131202690000,
"dateTo" : -3840351829778683400,
"recordId" : 6,
"account" : "6789189790191"
}, {
"messageId" : 1234,
"markerId" : "T",
"dateFrom" : 6436058131202690000,
"dateTo" : -3840351829778683400,
"recordId" : 7,
"city" : "San Fransisco"
} ]
But still I dont now how to remove/filter records which have idNumber and accountNumber fields(in this case records 4,5,6). Someone can help me?
