Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
ShZ
Contributor II
Contributor II

Get value from a table in tExtractJSONFields component

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 :

0695b00000rc5LWAAY.png

But it seems that I have no output row :

0695b00000rc5DKAAY.png

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"

}

Labels (4)
1 Solution

Accepted Solutions
jonlar
Contributor II
Contributor II

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"

 

0695b00000rcd9GAAQ.png 

0695b00000rcdDHAAY.png 

Hope this helps

View solution in original post

3 Replies
jonlar
Contributor II
Contributor II

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"

 

0695b00000rcd9GAAQ.png 

0695b00000rcdDHAAY.png 

Hope this helps

ShZ
Contributor II
Contributor II
Author

Hi jonlar,

 

Thanks a lot, this helped 😊

jonlar
Contributor II
Contributor II

My pleasure 🙂 Glad that helped!