Extracting data from a Json array (collection)

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

Why Companies Move to the Cloud: 7 Success Stories

Learn how and why companies are moving to the Cloud

Read Now

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch