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