Because Witango has the JavaScript engine built in this is really a trivial
problem...
Put the JSON array into a variable <@ASSIGN local$JSON <@ARG myJson>>
Use Witango's @SCRIPT to read the variable
var someJSON = server.getVariable('JSON','local');
@INCLUDE the JSON.js or JSON2.js from Douglas' site (www.json.org)
use the included file's method to parse the JSON string, or use eval() if it
comes from a trusted source.
var objJSON = parseJSON(JSON);
Then create an array, "walk" the object and convert it's contents into an
array, like so.
var count = 0;
for (i in objJSON) {
array[count] = objJSON[i];
count++;
}
then assign the array to a Witango variable
server.setVariable('JSONout',array,'local');
@@local$JSONout is now your array!
Done!
Anthony -
----- Original Message -----
From: GK
To: [email protected]
Sent: Sunday, 02 December, 2007 09:16
Subject: Witango-Talk: parsing question
Hi, would someone be able to help me parse the following json code into a
witango array.
({
"items":[
{
"productID":"1",
"itemDesc":"computer",
"cost":"10.00"
},
{
"productID":"2",
"itemDesc":"computer2",
"cost":"12.00"
}
]
})
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf