Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
I am very new to Talend and started to develop jobs on my own with the online documentation.
My input is a CSV file which contains an ID list. I am iterating on each ID from this list to make an API call thanks to the tRestClient component. The JSON response shows a table containing many events related to the object (see at the end of the post).
My goald is to get the EventDate value corresponding to the event having EventType = 5 for my current Id.
I put a JSONPath expression (which seems to work as expected) to filter my result
in my tExtractJSONFields
and mapped the "EventDate" field :But it seems that I have no output row :
Can someone help me with that issue ?
Thanks a lot.
Full JSON response :
{
"ResultItem": [
{
"EventDate": "2023-02-08T13:32:04.937Z",
"EventType": 5,
"UserId": "05c92833-a140-4fc7-9484",
"UserLastName": "DUPONT",
"UserFirstName": "Martin",
"UserMail": "martin.dupont@company.com",
"Description": "Event 5 description",
"ElementOldVersion": null
},
{
"EventDate": "2023-02-08T13:30:51.410Z",
"EventType": 2,
"UserId": "5dd93538-5160-492b-9552",
"UserLastName": "THOMAS",
"UserFirstName": "Robert",
"UserMail": "robert.thomas@company.com",
"Description": "Event 2 description",
"ElementOldVersion": null
},
{
"EventDate": "2023-02-08T13:24:07.140Z",
"EventType": 1,
"UserId": "97da651a-1ff4-45cd-bd5a",
"UserLastName": "PETIT",
"UserFirstName": "Luc",
"UserMail": "luc.petit@company.com",
"Description": "Event 1 description",
"ElementOldVersion": null
},
{
"EventDate": "2023-02-08T13:23:15.993Z",
"EventType": 9,
"UserId": "97da651a-1ff4-45cd-bd5a",
"UserLastName": "PETIT",
"UserFirstName": "Luc",
"UserMail": "luc.petit@company.com",
"Description": "Event 9 description",
"ElementOldVersion": null
}
],
"ResultCode": 0,
"Message": "Operation successful"
}
Hi,
First off your filter will not work as intended. As you can see from your screen shot, there is no outputted data from your tExtractJson component. To fix this, simply remove the single quotes from the filter value since the field type is a numerical value and not a string. So your filter should look like this -> "$.ResultItem[?(@.EventType == 5)]"
Then to retrieve the EventDate field, simply use the following expression "$.EventDate"
Hope this helps
Hi,
First off your filter will not work as intended. As you can see from your screen shot, there is no outputted data from your tExtractJson component. To fix this, simply remove the single quotes from the filter value since the field type is a numerical value and not a string. So your filter should look like this -> "$.ResultItem[?(@.EventType == 5)]"
Then to retrieve the EventDate field, simply use the following expression "$.EventDate"
Hope this helps
Hi jonlar,
Thanks a lot, this helped 😊
My pleasure 🙂 Glad that helped!