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: 
Anonymous
Not applicable

json output... almost there. i need arrays and it's creating objects

newbie to TOS (5.3) familiar with json, i think the json TOS is producing is "correct", it's just my endpoint wants arrays not objects
big picture... i'm trying to read a csv, convert each record to json and call a rest api to insert. I want this...
,
"FirstName": ,
"LastName":
},
"xref":
}
]
I'm getting this
{
"type":"conf/nodeTypes/Person",
"attributes": {
"Name": {
"type":"conf/nodeTypes/Person/attributes/Name",
"value":"DavidCole"
},
"FirstName": {
"type":"conf/nodeTypes/Person/attributes/FirstName",
"value":"David"
},
"LastName": {
"type":"conf/nodeTypes/Person/attributes/LastName",
"value":"Cole"
}
},
"xref": {
"type":"conf/sources/IMD",
"value":"1",
"url":" www.domainName.com"
}
}
Problems...
1. JSON is output as objects {...} not Arrays (see Name, FirstName, etc.) maybe technically that's ok, it's valid JSON, but my endpoint wants Arrays.
2. I'm not getting the surrounding brackets... I was able to use TFileOutputJSON to add brackets but
A. I don't want to go to a file
B. It does all my rows not one at a time
I tried a bunch of things but can't force an array. I posted the job stream, using viewers for debug, not very interesting.
any suggestion would be welcomed.
BTW... if someone had an example of process a record POST to REST, read response, process next... that would be helpful, i'll post a separate thread as well.
thanks for reading.
0683p000009MEnU.png
Labels (4)
20 Replies
Anonymous
Not applicable
Author

Hi
We usually use a tRestClient component to call a rest web service, and post a request with json format, you can find an example in this topic:
https://community.talend.com/t5/Design-and-Development/resolved-Input-for-Rest-Body-without-Root-nod...
But, it don't output the json request with Arrays format on tXMLMap.
Shong
Anonymous
Not applicable
Author

We are working on better support for arrays in XML to JSON auto-conversion supported by tRESTClient
Cheers, Sergey
Anonymous
Not applicable
Author

Any update on this?  It's been a couple years now and wondering if Talend has any solutions to this problem?
Thanks
Anonymous
Not applicable
Author

Hi,
Any update on this one? I am also trying to use tXMLmap to output array of JSON objects and it is not working. I am using Talend 5.5.
Thanks,
Gowri
Anonymous
Not applicable
Author

Any update on this?  This is a hot topic in the Talend community and it needs attention.  Any help would be greatly appreciated.
Anonymous
Not applicable
Author

We are also interested in finding a solution to this.
We have a data source passed to a tXMLMap component that loops object according to this structure:
<root>
   <person name="" />
</root>

If the person tag is looped having 2 rows (name1 and name2) would produce the following json, correctly:
{ person:  }

But if it's only one row (name1) the following json is produced:
{ person: { name="name1" } }

I guess this is a result of talend placing looped objects as tags, and one single tag has no indication of being a looped entity.
Regardless, this needs to be resolved for the JSON output to be accurate. Consuming systems will otherwise have to validate the json outcome, or we need to manually change the string before passing it as a response.
rafaeltrein
Contributor
Contributor

Hi,
We are also waiting for someone who make this structure works. Is there any news?
Thanks
Rafael
Anonymous
Not applicable
Author

Anyone solved this problem?
How can I convert json objects into arrays of objects?
Anonymous
Not applicable
Author

Any update with this? I'm facing the same problem.