tRestResponse Json not displaying all rows

Highlighted
Six Stars

tRestResponse Json not displaying all rows

Goal is to enter account nr on url then it pulls all accounts and devices linked to it.

 

My tRestresponse only displays one row as results 

 

{"LINK":{"accounts":{"accountnr":"EEE","entityname":"Ku","entid":93},"devices":{"devid":129,"devicename":"Ku Bha Service Station"}}}

 

While tlog displays all rows

{"LINK":{"accounts":{"accountnr":"EEE","entityname":"Ku","entid":93},"devices":{"devid":129,"devicename":"Ku "}}}
{"LINK":{"accounts":{"accountnr":"AAA","entityname":"Ku2","entid":93},"devices":{"devid":155,"devicename":"Ku2 "}}}

 

 

 


Accepted Solutions
Highlighted
Six Stars

Re: tRestResponse Json not displaying all rows

I just needed to add on tXMLmap all in one = true.

 

 

View solution in original post


All Replies
Highlighted
Sixteen Stars
Sixteen Stars

Re: tRestResponse Json not displaying all rows

As we can't guess what it looks like, share your job design + settings for related components

TRF
Highlighted
Six Stars

Re: tRestResponse Json not displaying all rows

 
Highlighted
Six Stars

Re: tRestResponse Json not displaying all rows

talend 1.png

talend1 (2).png

Highlighted
Six Stars

Re: tRestResponse Json not displaying all rows

I just needed to add on tXMLmap all in one = true.

 

 

View solution in original post

Highlighted
Six Stars

Re: tRestResponse Json not displaying all rows

 @TRF 

@kzone 

@rhall_2_0 

 

I now need to display the Json document much neater. currently it looks like

talend 1.png

 

where do I make this changes for Json to display as above

 

 

 


  
 

Highlighted
Sixteen Stars
Sixteen Stars

Re: tRestResponse Json not displaying all rows

Short answer: nowhere.

Don't format the JSON within the job, this is not necessary.

You just need it when a human have to read it.

In this case use your prefered text editor functionality to format the JSON flow. 

If your text editor doesn't allow you to do that, change it! Notepad++ (for example) is able to do that.


TRF
Highlighted
Six Stars

Re: tRestResponse Json not displaying all rows

@TRF 
@kzone @rhall_2_0 

There is the loop sequence option I read about on txmlMap (...) next to loop 

txmlmap-loop_sequence.png

but I happen to not have the edit loop sequence. I'm I missing something

talend 1.png

 

 

Highlighted
Community Manager

Re: tRestResponse Json not displaying all rows

I'm sorry I am not sure what you are asking for. Can you explain in a bit more detail. Maybe point to where you read about this and give an example of what you are trying to achieve.

Highlighted
Six Stars

Re: tRestResponse Json not displaying all rows

L1 (6).pngtalend2 (2).pngtalend 1.png

Highlighted
Six Stars

Re: tRestResponse Json not displaying all rows

@rhall_2_0I'm trying to display the json in an array as above. I managed to loop

Highlighted
Community Manager

Re: tRestResponse Json not displaying all rows

If you want to add an array to the JSON you need to build it with a tWriteJSONField component and not a tXMLMap. Arrays are not native to XML so when the XML is converted to JSON it will return the data as a loop of elements.

 

I've just knocked up a quick example. It is very basic, but should give you an idea. My job looks like this...

 

Screenshot 2020-03-10 at 10.59.22.png

 

My tFixedFlowInput component holds this data....

Screenshot 2020-03-10 at 10.59.34.png
I'm aiming for the "newColumn1" values to be in an array. 

I configure the tWriteJSONField's mapping as below.....

Screenshot 2020-03-10 at 10.59.52.png

Then I set the "Group By" field to group by the "newColumn" column (...the column I set my Loop on).

 

Screenshot 2020-03-10 at 11.00.58.png

 

The output I get can be seen below....

 

{"rootTag":{"newColumn":["newLine","newLine","newLine","newLine"],"newColumn1":"1"}}

....or in a more readable format.....

{
   "rootTag":{
      "newColumn":[
         "newLine",
         "newLine",
         "newLine",
         "newLine"
      ],
      "newColumn1":"1"
   }
}
Highlighted
Six Stars

Re: tRestResponse Json not displaying all rows

@rhall_2_0  that's great but my problem now is linking

 

restRequest-->tsetGlobalVar--->tdbRow--->tfixedFlowInput

It doesn't allow main link 

Highlighted
Community Manager

Re: tRestResponse Json not displaying all rows

You don't need to use a tFixedFlowInput component. I simply used that to hardcode my example data. Your data will not be hardcoded. The only component you care about in my example is the tWriteJsonField

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 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 3

Read about some useful Context Variable ideas

Blog