2017-03-04 9 views

答えて

0

PHPのJSONエンコードデータ

$data['postId'] = 123; 
 
$data['title'] = "Your titile"; 
 
$data['permalink'] = "http://smddtech.com"; 
 
$data['content'] = "your content"; 
 
$data['date'] = "2017-03-05"; 
 
$return['data'] = $data; 
 
echo json_encode($return); 
 
exit();

あなたはバレーボール応答してデータを取得することができます。 See google volley documentation。以下のコードバリエーションのJSONObjectレスポンスとそれをループする方法を参照してください。私たちは、あなたが直面している実際の問題についての情報なしにどのように役立つか

JSONArray newsItem=response.getJSONArray("data"); 
 
for (int loop=0;loop<newsItem.length();loop++) 
 
{ 
 
    JSONObject tempObject=newsItem.getJSONObject(loop); 
 
    int postId=tempObject.getInt("postId"); 
 
    String title=tempObject.getString("title"); 
 
    String permalink=tempObject.getString("permalink"); 
 
    String content=tempObject.getString("content"); 
 
    String date=tempObject.getString("date"); 
 
}

関連する問題