我在获取一维时遇到问题, JSON
请指导我问题出JSON
在我的代码中还是我的代码中?
JSON:
{
"data": {
"id": "S000010",
"name": "ZS Solutions",
"email": "zswebs@gmail.com",
"phone": "051-1234567",
"address": "p.o.box 123",
"about": "im the company\r\nHAhahhaa"
}
}
Android活动JSON
检索代码:
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
// TODO Auto-generated method stub
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("abc.php?Id="+id+"");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse hresponse = httpclient.execute(httppost);
HttpEntity entity = hresponse.getEntity();
is = entity.getContent();
String result=co(is);
JSONObject json=new JSONObject(result);
JSONArray a= json.getJSONArray(data);
for (int i = 0; i <= a.length(); i++) {
json = a.getJSONObject(i);
String cname=json.getString("name");
String cemail=json.getString("email");
String cphone=json.getString("phone");
String caddress=json.getString("address");
String cabout=json.getString("about");
Log.w("DATA ","NAME "+cname+"E-mail "+cemail+"Phone "+cphone+"ADDRESS"+caddress+"ABOUT"+cabout);
}
}
catch(Exception e){}