Performing a JSON Deserialization in Talend

0 votes

Following is the sample of the JSON file I need to deserialize:

{
          "ryan@toofr.com": {
            "confidence":119,"email":"ryan@toofr.com","default":20
          },
          "rbuckley@toofr.com": {
            "confidence":20,"email":"rbuckley@toofr.com","default":15
          },
          "ryan.buckley@toofr.com": {
            "confidence":18,"email":"ryan.buckley@toofr.com","default":16
          },
          "ryanbuckley@toofr.com": {
            "confidence":17,"email":"ryanbuckley@toofr.com","default":17
          },
          "ryan_buckley@toofr.com": {
            "confidence":16,"email":"ryan_buckley@toofr.com","default":18
          },
          "ryan-buckley@toofr.com": {
            "confidence":15,"email":"ryan-buckley@toofr.com","default":19
          },
          "ryanb@toofr.com": {
            "confidence":14,"email":"ryanb@toofr.com","default":14
          },
          "buckley@toofr.com": {
            "confidence":13,"email":"buckley@toofr.com","default":13
          }
        }

I am accessing this data using a tAmazonMysqlInput component and with the retrieval of each line of data, I need to invoke the API which gives me the first name, the last name and the company changes every time. Following is the screenshot of my Job:image

From the API I am forwarding the data to a tExtractJSONFields component which will then send it to the tLogRow component. tLogRow component will be then displaying the extracted data on the console. But my issue is, I am not able to configure the tExtractJSONFields component to show each row data on the console via tLogRow.

Please help me in configuring the tExtractJSONFields component. For your better understanding, I am adding the snapshot of my tExtractJSONFields component’s current configuration.

image

Apr 19, 2018 in Talend by geek.erkami
• 2,680 points
1,882 views

1 answer to this question.

0 votes

tExtractJSONFields component helps in extracting the desired data from incoming JSON fields based on the XPath or JSONPath query. Thus while working with it, two things you must pay attention to are:

  1. a valid XPath loop point

  2. A valid XPath mapping structure

You might know that while working with XPath in Talend each value needs a unique key. Which means your input data is incorrect:image

Instead, what you can use is:

 {
      "contact": {
        "confidence":119,"email":"ryan@toofr.com","default":20
      },
      "contact": {
        "confidence":20,"email":"rbuckley@toofr.com","default":15
      },

So, now the looping point is “/contact” and the mapping for:

“Confidence” -->‘confidence’,

“Email”--> ‘email’

Remember, it becomes the opposite for the “default”.

Hope this will help!

Join the Talend course today to know more about and become expert.

Thanks.

answered Apr 19, 2018 by code.reaper12
• 3,500 points

Related Questions In Talend

0 votes
1 answer

Creating a New Project in Talend Open Studio

Before you switch over to a new ...READ MORE

answered Apr 18, 2018 in Talend by misc.edu04
• 1,450 points
1,698 views
0 votes
1 answer

How to generate multiple rows from a single row in Talend?

I think using tJavaFlex, tMap and tFlowToIterate ...READ MORE

answered Apr 18, 2018 in Talend by code.reaper12
• 3,500 points
7,252 views
0 votes
1 answer
0 votes
1 answer

Naming the output based on a column value in Talend

You can try to solve this problem ...READ MORE

answered Apr 19, 2018 in Talend by 93.lynn
• 1,600 points
2,279 views
0 votes
1 answer

tWaitForFile component insufficiency in Talend

Regarding your first issue, tWaitForFile component provides ...READ MORE

answered Apr 11, 2018 in Talend by geek.erkami
• 2,680 points
2,149 views
+1 vote
1 answer
0 votes
2 answers

Closed loop in Talend

Hi, Talend specifies that tUnite cannot be ...READ MORE

answered Aug 23, 2019 in Talend by vinceall
1,867 views
0 votes
1 answer

Parsing JSON in Talend

While working with JSON files, one thing ...READ MORE

answered Apr 3, 2018 in Talend by code.reaper12
• 3,500 points
3,576 views
0 votes
2 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP