Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
nvtd4000
Contributor III
Contributor III

tExtractJsonFields doesn't parse json request properly

I am using Talend 7.3.1 for BigData Platform.

I have a rest service with request is Json format String (bookList with 2 books).

{ "bookList": [ {"onSale": false,"book": [ {"name":"book1","id":1}, {"name":"book2","id":2 } ] } ] }

 

What i want is : after running tExtractJsonFields, it should return an array of 2 elements: { "name": "book1", "id":1} and { "name": "book2", "id":2 }.

 

The jsonpath i used is $.bookList[*].book[*]. But What i have in tLogRow is only 1 string includes 2 elements. This is not what i want

.-------------------------------------------------.

|          tLogRow_1          |

|=-----------------------------------------------=|

|single_book                   |

|=-----------------------------------------------=|

|[{"name":"book1","id":1},{"name":"book2","id":2}]|

'-------------------------------------------------'

 

Bellow is what i want to have. It should have 2 elements. Do you know how to do that?

.-------------------------------------------------.

|          tLogRow_1          |

|=-----------------------------------------------=|

|single_book                   |

|=-----------------------------------------------=|

|{"name":"book1","id":1}

{"name":"book2","id":2}

'-------------------------------------------------'

Bellow is what I have with the Talend Job:

0695b00000IfD1kAAF.png0695b00000IfD1pAAF.png

1 Reply
manodwhb
Champion II
Champion II

@Not defined Not defined​ , After tExtractJson use the tNormalize component and split based on }, then you will get two records and the use tMap if you want to remove any extra characters like [ or ] and check if you want to add any character if required like { or }

 

this is one way,since they are multiple ways.

 

Thanks,

Manohar