JSON in Flex. "Access of undefined property JSON"
Solution 1
You need to download, install, and reference the utility library that contains the JSON routines. See http://labs.macromedia.com/wiki/index.php/ActionScript_3:resources:apis:libraries#corelib
Did you do that, and include it in your project?
Solution 2
Here is the new location for corelib: https://github.com/mikechambers/as3corelib (as of Feb. 2011 when I'm writing this)
Solution 3
Use the below code
var arr:Array = (com.adobe.serialization.json.JSON.decode(rawData) as Array);
instead of
var arr:Array = (JSON.decode(rawData) as Array);
Dont forget to import below package import com.adobe.serialization.json.JSON;
its working good for me!
Alex
Updated on August 06, 2022Comments
-
Alex almost 2 years
I am trying to parse JSON in an Adobe Flex app, using http://www.mikechambers.com/blog/2006/03/28/tutorial-using-json-with-flex-2-and-actionscript-3/'>This Tutorial
Unfortunately, Flex Builder 3 is flagging a "Access of undefined property JSON" error on the line
var arr:Array = (JSON.decode(rawData) as Array);
I don't know what it wants, since I included the import line.
-
merv over 12 years-1 • "You have to use AIR 3..." is wrong. JSON support is also included in the Flash Player 11 (and up) build. You don't have to switch to an AIR project in order to enjoy the benefits of the native JSON support. See JSON Docs in Lang Ref. Please revise, and I'd be glad to +1 and remove my comment.