2016-07-03 53 views
0

以下はJSONです。私はカテゴリリストオブジェクトから "newsdetail"内のnews_titleを解析する必要があります。このデータを解析する正しい方法は何ですか?私を助けてください。Json配列とオブジェクトの解析

{"categorylist":[{"process":"news","ncid":"1"","newsdetail":[{"newsid":"604","category":"1","category_title":"","news_title":"just"},{"newsid":"606","category":"1","category_title":"","news_title":"fg"}]},{"process":"news","ncid":"2","newsdetail":[{"newsid":"477","category":"2","category_title":"","news_title":"way},{"newsid":"478","category":"1","category_title":"","news_title":"k"}]} 
+0

を持っているあなた 'JSON'は有効ではありません。ここを変更する - > http://www.jsoneditoronline.org/ –

+0

このjsonを解析するために何か試しましたか? –

+0

この問題のコードを見ることはできますか? –

答えて

1
{"categorylist":[{"process":"news","ncid":"1"" // cannot be double quotes come here. 
,"newsdetail":[{"newsid":"604","category":"1","category_title":"","news_title":"just"},{"newsid":"606","category":"1","category_title":"","news_title":"fg"}]},{"process":"news","ncid":"2","newsdetail":[{"newsid":"477","category":"2","category_title":"","news_title":"way},{"newsid":"478","category":"1","category_title":"","news_title":"k"}]} 

あなたはparsorの下に使用することができます..しかし、あなたの文字列データは、いくつかの問題

try { 

JSONObject jsonObject = new JSONObject(data); 
        JSONArray category_list = jsonObject.getJSONArray("category_list"); 
        for (int i = 0; i < category_list.length() ; i++) { 
         // here you get news title for each news 
         String newsTitle = category_list.getJSONObject(i).getString("news_title"); 
        } 


       }catch (JSONException e){ 

       } 
関連する問題