JSON to ASON

I have blogged about JSON before but forgot to provide an example for getting JSON into AS. I saw a query on FlexIndia on JSON, so I thought I’ll post it now. The problem is to convert JSON to ActionScript Objects (or ASON). You can first try the demo application to see if this is what you are looking for…

In the app, you can either paste a URL (provided you have the security permissions) of a JSON to convert or paste your own JSON into the textarea and convert it.

This is what you need to do to get this working…

  1. Go to AS3CoreLib on Google Code and download the corelib-.90.zip file and extract it
  2. Get the corelib.swc from the /bin directory
  3. Download the app source or write your own code 🙂
  4. Do one of the following:
    If you are using FlexBuilder:

    1. Right click on your project go to Properties
    2. Navigate to Flex Build Path -> Libraries Tab -> Add SWC
    3. Now add the corelib.swc to your project
    4. Confirm that you have the line “import com.adobe.serialization.json.JSON;” in the code
    5. Run and Have Fun 🙂

    If you are using the command-line compiler:

    1. Place the swc in the directory of your mxml code
    2. Confirm that you have the line “import com.adobe.serialization.json.JSON;” in the code
    3. Type the following on the command line
    4. mxmlc -include-libraries=corelib.swc JSONTest.mxml
    5. Run and Have Fun 🙂
Advertisements

8 Responses to JSON to ASON

  1. Kalyan says:

    Hi ,

    Thanks for your help.It really works fine. Thanks once again

  2. raghunathrao says:

    No problem… A pleasure 🙂

  3. […] I used the as3corelib to convert the JSON to an AS Object. I then embedded an Indic Font into my App and used it to render the text. The result is what you […]

  4. […] Effects by Alex Uhlmann in this example. So be sure to compile the source code with the SWC (check this post if you don’t know how to compile in an external swc into your […]

  5. jaime From Chile says:

    Thank you, with this can resolve a problem intallations Json, and now all is working

    thx

  6. Bill says:

    Raghu, how do you access data from an external JSON feed? I’m new to Flex. I know about the crossdomain.xml file, which I’m including in the directory on my localhost but it doesn’t seem to work.

  7. Remya says:

    hi,
    am very new to Flex , your blog helped me to fix the error.

    thanx
    remya

  8. Hi,

    Thank you very much…

    I searched more than hour for the below error
    “1172: Definition com.adobe.serialization.json:JSON could not be found.”

    I followed your guidelines, now its working for me.

    thanks again.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s