我使用下面的Android JSON解析的代碼,但我得到的錯誤:Android的JSON解析錯誤
org.json.JSONException: End of input at character 0 of
03-23 13:54:28.905: W/System.err(1448): org.json.JSONException: End of input at character 0 of
public void fetchOriginatorName()
{
try {
URL url = new URL("http://financemyhome.com/webservice/bio.php");
URLConnection urlconn = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(urlconn.getInputStream()));
String line;
while ((line = in.readLine()) != null)
{
System.out.println("Line = "+line);
System.out.println("Length = "+line.length());
JSONArray ja = new JSONArray(line);
for (int i = 0; i < ja.length(); i++)
{
JSONObject jo = (JSONObject) ja.get(i);
id.add(jo.getString("id").toString());
name.add(jo.getString("first_name").toString()+jo.getString("last_name"));
designation.add(jo.getString("designation").toString());
email.add(jo.getString("email").toString());
cell.add(jo.getString("phone").toString());
nmls.add(jo.getString("nmls").toString());
imageurl.add(jo.getString("picture-path").toString());
office.add(jo.getString("address"));
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
把你的全logcat的和你的JSON性反應的有效.... – 2012-03-23 14:03:22