Veer7
Veer7

Reputation: 21473

how do I parse JSON in action script?

I want to parse the JSON

[ 
{ 
    "food": [ 
        { 
            "name": "pasta", 
            "price": 14.50, 
            "quantity": 20 
        }, 
        { 
            "name": "soup", 
            "price": 6.50, 
            "quantity": 4 
        } 
    ] 
}, 
{ 
    "food": [ 
        { 
            "name": "salad", 
            "price": 2.50, 
            "quantity": 3 
        }, 
        { 
            "name": "pizza", 
            "price": 4.50, 
            "quantity": 2 
        } 
    ] 
} 
] 

How can I get elements from the JSON like each array and element from each array. I have more bigger JSON than this. Line by line parsing of which takes several minutes. Any solution to do it faster.
Expecting link of org JSON util or such and some code for how to use it

Upvotes: 0

Views: 182

Answers (1)

Sam DeHaan
Sam DeHaan

Reputation: 10325

as3corelib is a library that includes a JSON static class that has a function JSON.parse(). This should be already included in your flash project by default.

JSON.parse() takes a String and returns your parsed JSON object. If you need assistance interpreting/accessing the results, there are numerous tutorials for using JSON.parse() on the internet.

Upvotes: 3

Related Questions