Я пробовал все, и я не могу тайному этот JSON объект в JSON массив, он бросает JSON ExceptionЭтот объект JSON не могут быть преобразованы в JSON массив
Вот Logcat:
11-13 11: 19: 53.964: W/System.err (8642): at org.json.JSON.typeMismatch (JSON.java:111) 11-13 11: 19: 53.964: W/System.err (8642): at org.json.JSONArray (JSONArray.java:91) 11-13. 11: 19: 53,964: Вт/System.err (8642):. на org.json.JSONArray (JSONArray.java:103)
Вот файл в формате JSON:
{ "GetGISResult": [{ "Активный": правда, "CategoryID": 1, "CreateDate": нулевой, "CreateUser": нулевой, "Description_ar":» التا " "Description_en": "هعلل", "Электронная почта": "لتتالت", "Шир": 30.0764857, "Long": 31,30658, "Мобильный": "تالتال", "SectionID": 9, "SectionName_ar":" 1" , "SectionName_en": "لاتا", "UpdateDate": нулевой, "UpdateUser": нулевой}, { "Активный": правда, "CategoryID": 1, "CreateDate": нулевой, "CreateUser": нулевой,» Description_ar ":" التا " "Description_en": "هعلل", "Электронная почта": "لتتالت", "Шир": 30.0892124, "Long": 31.2892342, "Мобильный": "تالتال", "SectionID": 10," SectionName_ar ":" 2" , "SectionName_en": "لاتا", "UpdateDate": NULL, "UpdateUser": нулевой}, { "Активный": правда, "CategoryID": 1, "CreateDate": NULL, "CreateUser" : нулевой, "Description_ar": "التا", "Description_en": "هعلل", "E почта ":" لتتالت " "Шир": 30.0433341, "Long": 31.3006067, "Мобильный": "تالتال", "SectionID": 15, "SectionName_ar": "7", "SectionName_en": "لاتا"," UpdateDate ": нулевой," UpdateUser ": нулевой}]}
Вот мой код:
try {
HttpResponse response = httpClient.execute(httpGet);
int responsecode = response.getStatusLine().getStatusCode();
if (responsecode == 200) {
InputStream in = response.getEntity().getContent();
resultstring = convertinputStreamToString(in);
System.out.println("resultstring>>> "+resultstring);
try {
JSONArray stores = new JSONArray(resultstring);
for (int i = 0; i < stores.length(); ++i) {
JSONObject jo = (JSONObject) stores.get(i);
// TO-DO JSON here
result.add(convertToStores(jo));
Log.v("check on adding Lat to list", result.get(i)
.getLat()+"");
Log.v("check on adding Lon to list", result.get(i)
.getLong()+"");
Log.v("check on adding Description to list",
result.get(i).getDescription_ar());
Log.v("check on adding Email to list",
result.get(i).getEmail());
Log.v("check on adding Mobile to list", result
.get(i).getMobile());
}
} catch (JSONException c) {
Log.v("Exception >>>", c.getMessage().toString());
c.printStackTrace();
}
long total = 0;
byte data[] = new byte[1024];
while ((count = in.read(data)) != -1) {
total += count;
// publishing the progress....
// After this onProgressUpdate will be called
setProgress((int)((total*100)/1000));
}
}else if(responsecode != 200){
Toast.makeText(getApplicationContext(), "Your connection is break down please check your connection ..", Toast.LENGTH_LONG).show();
}
public static String convertinputStreamToString(InputStream ists)
throws IOException {
if (ists != null) {
StringBuilder sb = new StringBuilder();
String line;
try {
BufferedReader r1 = new BufferedReader(new InputStreamReader(
ists, "UTF-8"));
while ((line = r1.readLine()) != null) {
sb.append(line).append("\n");
}
} finally {
ists.close();
}
return sb.toString();
} else {
return "";
}
}
Можете ли вы поместить сообщение об ошибке здесь? –