Extracting data from a Json array (collection)

Highlighted
Five Stars

Extracting data from a Json array (collection)

Hello everyone,

 

I haven't yet found a way to extract the data given by my tREST component.

Here's the scenario :

 

Capture du 2019-01-24 14-26-21.png

My data is a JSON array like :

[
{"@id":201215,"link":{"@rel":"self","@href":"\/api\/groupe\/201215"},"libelle":"test \u00e0 moi 46546846","abrege":"test_dependances_2","entites":"Personne","description":null},
{"@id":201219,"link":{"@rel":"self","@href":"\/api\/groupe\/201219"},"libelle":"test \u00e0 moi 46546846","abrege":"test_dependances_2","entites":"Personne","description":null}
]

 The tExtractJSONfields is filled that way :

 

Capture du 2019-01-24 14-29-40.png

I can't seem to obtain the response I wish for.

 

I checked with a tlogRow immediately after the tREST component and the answer is correct so far.

 

Do you have any idea what's wrong with my reasoning ?

 

Thanks for your suggestions and help !

 

Best regards,

 

Ema


Accepted Solutions
Nine Stars

Re: Extracting data from a Json array (collection)

Hi,

 

I think your JSON Query for each column is incorrect, try it as "$.@id"

 

Regards David
Dont forget to give Kudos when an answer is helpful or mark the answer as the solution.

All Replies
Five Stars

Re: Extracting data from a Json array (collection)

Hi,

Further info : error log shows :

com.jayway.jsonpath.InvalidPathException: Invalid path $id

=> if I replace the "@" before the tExtractJSONfields, it does the trick;

But, is it really impossible to use the character "@" in field name ?

Thank you all for your insight,

Ema

Nine Stars

Re: Extracting data from a Json array (collection)

Hi,

 

I think your JSON Query for each column is incorrect, try it as "$.@id"

 

Regards David
Dont forget to give Kudos when an answer is helpful or mark the answer as the solution.
Five Stars

Re: Extracting data from a Json array (collection)

Hi,

Thank you so much, It worked !!!!

Best regards !

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

APIs for Dummies

View this on-demand webinar about APIs....

Watch Now

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog