Android が PHP からデータを返そうとすると、次のエラーが発生します。
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result=sb.toString();
} catch(Exception e) {
Log.e("log_tag", "Error converting result "+e.toString());
}
//parse json data
try {
JSONArray jArray = new JSONArray(result);
//-----------------------------------------
//----------------------------------------
for(int i=0;i<jArray.length();i++) {
JSONObject json_data = jArray.getJSONObject(i);
map = new HashMap<String, String>();
map.put("nomclt", (String) json_data.get("nomclt"));
map.put("prenomclt", (String) json_data.get("prenomclt"));
// map.put("adresse", (String) json_data.get("adresse"));
//enfin on ajoute cette hashMap dans la arrayList
listItem.add(map)
スクリプトphp
<?php
header('Content-type: application/json');
mysql_connect("localhost","root","");
mysql_select_db("test");
$sql=mysql_query("SELECT * FROM client");
$output = array();
while($row=mysql_fetch_array($sql))
$output[]=$row;
print(json_encode($output));
mysql_close();
?>