Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Parse JSON column

Hi,

I have a text file with 2 columns:

  • First column contains Keywords. e.g. "Apple TV"
  • Second column contains one JSON with all the returned items for that keyword.

The delimiter between the two columns are 2 pipe delimiters "||"

Example of the file:

apple tv||{"items":{"items": {"item":[{"itemId": 35364564576},{"itemId": 23425436456}]}}}
amazon echo||{"items":{"items": {"item":[{"itemId": 4563457657},{"itemId": 67868678678}]}}}

I need to build a job that extract the keyword and extract it's relevant items from the JSON

How I would like the output to look like:

KeywordItemID
apple tv35364564576
apple tv23425436456
amazon echo4563457657
amazon echo67868678678


I know it might be very simple, but It's been a while since I used Talend and from some reason can't get it work.

Thanks in advance for your help!

 

Labels (3)
1 Solution

Accepted Solutions
vboppudi
Partner - Creator III
Partner - Creator III

Hi ,

 

Please find the job below to split json field.

 

0683p000009LsoW.png0683p000009Lt1Z.png

 

Regards,

 

 

View solution in original post

4 Replies
Anonymous
Not applicable
Author

First you need to split the columns of your file. I'm assuming you can do that using the tFileInputDelimited component. You should have 2 columns.

Next you need a tExtractJsonField component. There are 2 things to think about here; your keywords column needs to be a "pass-through" column (by that I mean no JSON Path should be specified), the items data will need a JSON path. BUT you will also need a Loop set.

Take a look at this question and see if you can extrapolate from it ( https://community.talend.com/t5/Design-and-Development/JSON-Array-values-to-Rows-is-there-a-better-w...).

Unfortunately I'm at an airport with just a smart phone so cannot really go into much more detail. Hope this helps.
vboppudi
Partner - Creator III
Partner - Creator III

Hi ,

 

Please find the job below to split json field.

 

0683p000009LsoW.png0683p000009Lt1Z.png

 

Regards,

 

 

Anonymous
Not applicable
Author

Super! thankssss !!
Anonymous
Not applicable
Author

Hello,

I am trying to parse data from a JSON file I have, I am using tFileInputJson and logging the rows.

When the file has only one record, the job runs fine and give me the desired result.

But when the file has more than one record, I get the error "Unable to find next state", I am attaching all the files.

Could you please let me know how I can run this job for the file with multiple records.

 

Please help!

 

Thanks,

Alok

 


Error.JPG
Job.JPG
Success.JPG
File_with_multiple_record.txt
File_with_Single_record.txt