我最近在我的服务器上设置了一个 php 页面,该页面贯穿我的数据库并将其输出到页面上。
JSONObject json = JSONfunctions.getJSONfromURL("http://abc.com/getjson.php");
try{
JSONArray myArray = json.getJSONArray("date");
for(int i=0;i<myArray.length();i++){
HashMap<String, String> map = new HashMap<String, String>();
JSONObject e = myArray.getJSONObject(i);
map.put("id", String.valueOf(i));
map.put("date", "date name:" + e.getString("date"));
map.put("activity", "activity: " + e.getString("activity"));
mylist.add(map);
}
[{"date":"2012-04-23","activity":"gym"},{"date":"2012-04-24","activity":"walking"}]