1

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
}
1
  • 1
    So you want to convert a perfectly good JSON array into a JSON object? Commented Mar 6, 2013 at 20:06

1 Answer 1

1

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));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.