Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Edith1
Creator
Creator

JSON Multiple Loop Elements using tReplicate to tExtractJSONField

I'm using tRESTClient to call a get REST API. In the JSON response, there's multiple loops and need objects from both loops.  I read to split the response data using tReplicate then use tHASHOutput & tHASHInput to combine the data needed. However, I cannot combine them because I need the id# for both tHASHOutput and the id# is only held in the 1st loop. I am using a file JSON for the tExtractJSONFields (see picture below of the mapping). 

As shown in the picture below, the output for the id# is all 1 string. I need to extract the id# in the 1st loop then extract the looping elements for that loop. How do I accomplish this?      

0683p000009MaBD.png

0683p000009MaCF.png

Labels (3)
7 Replies
Anonymous
Not applicable

Hi
Can you please show an example what you extract from loop1 and loop2? and what are you expected result?

Regards
Shong
Edith1
Creator
Creator
Author

Thank you Shong for your quick response! Smiley Happy

Below is a screenshot of the source schema. There's 2 loops: result[*] and attributes[*]. Those attributes belong to a result.id. For tExtractJSON_1, I am pulling result[*].id and result.name. In addition to this, I need attributeType.name and value from the 2nd loop for tExtractJSON_2. The screenshot below shows the preview where the result.id I am pulling from the 1st loop shows as 1 string for all the ids. The other 2 columns are fine, but I don't know how to split the id data into rows like the other 2.      

 

0683p000009Ma92.png

 

I'm using the JSON File above and here's a screenshot of tExtractJSONFields_1

0683p000009MZuW.png

 

Here's a screenshot of tExtractJSONFields_2

0683p000009MZox.png

Edith1
Creator
Creator
Author

Hi, just checking in to see if you need anything else from me. 

Anonymous
Not applicable

what are your expected result?
891;name1;value1
331;name2;value2
....
Is this your expected output? If so, as you did, use two tExtractJsonFields components for each loop element, one for result and another for attribute. In next subjob, add a new column for each data flow and set a sequence number for each row, this number will be the key for join on tMap.
Edith1
Creator
Creator
Author

Hello there, 

As you suggested, I'm extracting the 1st & 2nd loop separately, then I'm adding the seq#.  However, the sequece number is continuous and that's not what I was expecting.  I want to know how to extract the child loop and what parent it belongs to.

 

Please see the attachment with screenshots of the API response, what data I need, how I've been extracting the data multiple ways and not getting nowhere.  


Multi-Array API Response.doc.docx
tornilleiro
Contributor III
Contributor III

Hi edithmurillo,

 

What about put the two components tExtractJSONField in sequence. On the first tExtractJSONField you loop the result[*] without dig into attributes[*]. You pass the attributes[*] as a node for the following tExtractJSONField. In this second step e you can define other new loop over the attributes.

 

Regards

 

Edith1
Creator
Creator
Author

I figured out a way to get the result I needed using tHMap, now I need to figure out how to connect the tRestClient to the tHMap. Any suggestions?