Solved

How to use JSONDecoder ?

Posted on 2010-11-10
7
1,568 Views
Last Modified: 2012-05-10
Hi,

I like to decode a JSON string with Flash Builder 4.
So I include com.adobe.serializers.json but can't find any methode there for.

Can somebody show me how to use JSONDecoder please?

Thanks

Andre
0
Comment
Question by:andre72
  • 4
  • 3
7 Comments
 
LVL 17

Expert Comment

by:deepanjandas
ID: 34102199
//sample json data passed - [ {"name":"Jaylo", "number":"3243251"}, {"name":"Jenny", "phone":"8675309"}])

var jsonData:String = "[ {"name":"Jaylo", "number":"3243251"}, {"name":"Jenny", "phone":"8675309"}])";

var data:Array= JSON.decode(loader.data) ;
trace(People[0].name) ; //Jaylo
trace(People[0].number) ; //3243251
trace(People[1].name) ; //Jenny
trace(People[1].number) ; //8675309

Here the object returned is an Array; it can also be object.

Warm Regards
Deepanjan Das
http://deepanjandas.wordpress.com
0
 
LVL 17

Expert Comment

by:deepanjandas
ID: 34102244
Sorry dude, I copied it wrong above.
//sample json data passed - [ {"name":"Jaylo", "number":"3243251"}, {"name":"Jenny", "phone":"8675309"}])

var jsonData:String = "[ {"name":"Jaylo", "number":"3243251"}, {"name":"Jenny", "phone":"8675309"}])";

var data:Array= JSON.decode(jsonData) ;

Also try using ObjectUtils.toString(data);
trace(data[0].name) ; //Jaylo
trace(data[0].number) ; //3243251
trace(data[1].name) ; //Jenny
trace(data[1].number) ; //8675309

Here the object returned is an Array; it can also be object.

Warm Regards
Deepanjan Das
http://deepanjandas.wordpress.com
0
 

Author Comment

by:andre72
ID: 34102307
Yes I read some threads like this but I've no JSON.decode()

I thinks you use the workspace com.adobe.serialization but this one I've not available.
The one I found is called com.adobe.serializers and it doesn't contain decode() ...
0
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 
LVL 17

Accepted Solution

by:
deepanjandas earned 500 total points
ID: 34102335
Hi,
Kindly find the adobe package for JSON.

Warm Regards
Deepanjan Das
http://deepanjandas.wordpress.com
com.zip
0
 

Author Comment

by:andre72
ID: 34102716
deepanjandas thank you very much.
Maybe you can also tell a novice in which directory to place it best and how to referer it than to my project - or will Flex recognize it by itself than?
0
 
LVL 17

Expert Comment

by:deepanjandas
ID: 34102732
Do you have a src folder, so just paste the com folder under src and you should be done.


Warm Regards
Deepanjan Das
http://deepanjandas.wordpress.com
0
 

Author Closing Comment

by:andre72
ID: 34110317
Thanks for your support
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question