andre72
asked on
How to use JSONDecoder ?
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
I like to decode a JSON string with Flash Builder 4.
So I include com.adobe.serializers.json
Can somebody show me how to use JSONDecoder please?
Thanks
Andre
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
//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
ASKER
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() ...
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() ...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
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?
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
Warm Regards
Deepanjan Das
http://deepanjandas.wordpress.com
ASKER
Thanks for your support
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