Skip navigation
samir.amin
Currently Being Moderated

Parsing Json data to Array

Jun 18, 2012 11:24 PM

Tags: #flex #actionscript #json

i have json string which i want to parse in string and add in Array,
also i want to access this value as per field name to display in TextBox.

i have parse the json data in string format but i want to add it in array as per their field name,so that i can access it in textfields.

 

[{"userid":1,"uname":"andruw","address":"west","city":"london","email" :"andruw@example.com"},

{"userid":2,"uname":"pamela","address":"east","city":"london","email": "pamela@example.com"},

{"userid":3,"uname":"penny","address":"south","city":"paris","email":"penny@example.com"},

{"userid":4,"uname":"jhon","address":"north","city":"zurich","email":"jhon@example.com"}]

 
Replies
  • Currently Being Moderated
    Jun 19, 2012 1:09 AM   in reply to samir.amin

    Why do you wnat it string in hte first place, now you need to split it to get the info. The honest thing to do is to create a custom class to hold this info and populate the array with objects created from JSON. That way you can easily map data to UI controls.

     

    class Person

    {

        userId:int;

        uname:String;

        address:String;

        city:String;

        email:String;

     

    }

     

     

    My 2 cents,

    C

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 15, 2012 6:46 PM   in reply to Claudiu Ursica

    Hi Claudiu,

     

    I have a json data where the result is two layer down.

    If I get the parsed data and want the name I have to write jsonParsed.d.result[0].name, how would i create the class and how will I use the class.

     

    Right now I have:

     

    var jsonParsed:Object = JSON.parse(loader2.data);

     

    Thanks,

    Kim

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points