I’m trying to receive an array using URLLoader. I included ac3corelib to my project and declared JSON library: “import com.adobe.serialization.json.JSON;” However, when I use “JSON.decode(e.target.data)” I get an error “Access of undefined property JSON”.
Here is the code:
import com.adobe.serialization.json.JSON;
private function getContacts():void {
var contacts:URLLoader = new URLLoader();
contacts.addEventListener(Event.COMPLETE, onLoaded);
function onLoaded(e:Event):void {
var con:Object = JSON.decode(e.target.data);
}
contacts.load(new URLRequest("http://domain.com/cmd.php?action=contacts"));
}
Thanks in advance!
Use the below code
instead of
Dont forget to import below package
import com.adobe.serialization.json.JSON;
its working good for me!