Reputation: 5994
I'm new to JSON. This is the .json I want to decode but I always get this error:
JSONParseError: Unexpected h encountered
This is my code:
import com.adobe.serialization.json.JSON;
//
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest();
request.url = "twitter.json";
//
loader.load(request);
loader.addEventListener(Event.COMPLETE, decodeJSON);
//
function decodeJSON(event:Event):void {
var loader:URLLoader = URLLoader(event.target)
var jsonArray:Array = JSON.decode(loader.data);
}
What's wrong with it? Thanks.
Upvotes: 1
Views: 5097
Reputation: 21
It's an array not an object, so do this:
//var jsonArray:Array = JSON.decode(loader.data);
var jsonObject:Object = JSON.decode(loader.data);
Upvotes: 2