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
Highlighted
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.

View solution in original post


All Replies
Highlighted
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

Highlighted
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.

View solution in original post

Highlighted
Five Stars

Re: Extracting data from a Json array (collection)

Hi,

Thank you so much, It worked !!!!

Best regards !

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog