Hello,
I need to call a workflow from the REST API, eveything's working fine as long as I expect "simple" outputs like numbers or strings.
I want to get an array of strings, and when I get the output I get the following :
(...),"outputParameters":[{"name":"ResultArray","type":"Array/string","scope":"LOCAL"}],"startedBy":(...)
I can see my result array but how can I access the values ?
The ugly method would be to return a String representing the array with a separator, but I would like to avoid this method.
Any clues ?
Thanks in advance !
If the output validates as a valid JSON file (you can find JSON viewers / editors online) then a myObject = JSON.parse(outputString); will transform the JSON string in a javascript object.
Then you will be able to get porperties with i.e :
for each (var outputParameter in myObject.outputParameters
{System.log outputParameter.name}
Note: this is a pseudo code so you get the idea. To know the object structure check it in a JSON viewer.
If the output validates as a valid JSON file (you can find JSON viewers / editors online) then a myObject = JSON.parse(outputString); will transform the JSON string in a javascript object.
Then you will be able to get porperties with i.e :
for each (var outputParameter in myObject.outputParameters
{System.log outputParameter.name}
Note: this is a pseudo code so you get the idea. To know the object structure check it in a JSON viewer.
Thans for your reply, but I forgot to specify I call the workflow from an external tool (a website),
my problem is not how to parse the Json string i receive, but how to get to real arary and not just a string telling me I have an array.
If I try to be a bit clearer, the values in the array are not in the JSON I receive, the JSON (the interesting part) I receive is really :
"outputParameters":[{"name":"ResultArray","type":"Array/string","scope":"LOCAL"}], "
I can see it's an Array of string but how do i access it ?
I hope I am not too confusing.
Nevermind, that's my bad, I wasn't enable to access the info because my array was empty, that's why I couldn't see the values.
Thanks again.