Reputation: 7219
There is the native JSON.stringify method, but this is NOT what I need
I need to convert the following
[['user1',150],['user2',270],['user3',500]]
to a proper JSON object
{"user1" : 150,
"user2" : 270,
"user3" : 500
}
Upvotes: 1
Views: 2299
Reputation: 7219
ok answering my own question
var jsonOb={}
var L:int=testArray.length;
for(var i:int=0;i<L;i++){
jsonOb[testArray[i][0]]=testArray[i][1]
}
trace('jsonOb=='+jsonOb+ ' and JSON.stringify(jsonOb) = '+JSON.stringify(jsonOb));
Upvotes: 1