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

Announcements
Join us in Zurich on Sept 24th 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 
I couldn't create a json array in tjava row.can anyone help me out with the solution because I am new to this....
I am getting this o/p.
{"Customer":"JI0000","RecordType":"POH","Warehouse":"","RecordNumber":"000001","OrderDate":"20140730","Action":"A","SalesOrder":"01","Company":"56","InboundOrder":"P0001982"}
but I need this inside an array...
_AnonymousUser
Specialist III
Specialist III

Any news ?
The issue still occurs when using TOS for Big Data 6.2.1
stepro
Contributor
Contributor

I have the same problem: it returns:
{"types":{"symbolicName":}}

needed is:
{"types":
}

I have tried multiple ways, but there seems to be no way to create this using TXMLMAP and responste
Anonymous
Not applicable
Author

Is there Update on this I do have same isse. Not able to create a JSON file with array []
_AnonymousUser
Specialist III
Specialist III

So this post is 4 years old.  People are obviously still having problems with this issue.  Talend Team, can you please respond?  I'm having the same issue as everyone here and not sure how to resolve it.  
Thanks! 
Anonymous
Not applicable
Author

Create an attribute under the field that you want as an array and default it as an array.
_AnonymousUser
Specialist III
Specialist III

I'm ran into the same problem with Talend 6.3.1. Talend Team, any news for us?
_AnonymousUser
Specialist III
Specialist III

Create an attribute under the field that you want as an array and default it as an array.

I like this idea, but how do you "default it as an array"
Anonymous
Not applicable
Author

Hi
Type the word Array in the static Value column of the write Json task
@class - Attribute
set a fixed value - Array
Works for me

HTH
Anonymous
Not applicable
Author

Since this sounded indeed interesting, I checked it out. It seems to do the trick in forcing square brackets around the desired value if it has only on occurence.
Maybe I made some mistakes in my tWriteJSONField, but declaring for example my loop element as an array, I ended up with each element being an array inside an array of the loop elements. So it depends on how your JSON should look like, but it is still worth keeping in mind.
Btw: What worked for me,but it is not as neat and easy as some settings in tWriteJSONField, is manipulating the JSON String after tWriteJSONField by calling a self-written Java Routine which puts some [] around the content of a given element which I want to be an array. Maybe this is also an approach for others.