if(result != null)
{
try
{
JSONObject jobj = result.getJSONObject("result");
String status = jobj.getString("status");
if(status.equals("true"))
{
JSONArray array = jobj.getJSONArray("data");
for(int x = 0; x < array.length(); x++)
{
HashMap<String, String> map = new HashMap<String, String>();
map.put("name", array.getJSONObject(x).getString("header"));
map.put("date", array.getJSONObject(x).getString("date"));
map.put("description", array.getJSONObject(x).getString("description"));
list.add(map);
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
else
{
Toast.makeText(Calendar.this, "Network Problem", Toast.LENGTH_LONG).show();
}
它正在从给定的 JSON 中读取
{
result: {
data: [
{
header: "En övre rubrik här",
date: "10 Apr,2014",
description: "Test av en fin text. Om jag länkar. www.swerix.se Mer annat kanske. 0706300080 "
},
{
header: "Info 3",
date: "17 Apr,2014",
description: "Detta är en ny information. Skrivet över även hej hopp"
},
{
header: "testing news1",
date: "13 Mar,2014",
description: "this is testing news description12"
}
],
status: "true",
description: "Data found"
}