まずは JSON lintで JSONフォーマットの確認
http://www.jsonlint.com/
Json例
[
{
"title_name" : "タイトル" ,
"data_loop" : [
{
"id" : 1 ,
"text_name" : "テキスト1"
} ,
{
"id" : 2 ,
"text_name" : "テキスト2"
}
]
}
]
import com.adobe.serialization.json.JSON;
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
urlLoader.addEventListener(Event.COMPLETE, completeHandler);
urlLoader.load(new URLRequest("news.json"));
function completeHandler(e:Event):void
{
var json:String = URLLoader(e.currentTarget).data;
//デコード!!
var news:Array = JSON.decode(json);
//中身拝見
for(var i:int=0;i<news.length;i++)
{
trace(news[i].id, news[i].date, news[i].title, news[i].description);
}
}
引用:http://feb19.jp/blog/archives/000159.php