我的PHP腳本的JSON結果有問題。我無法在JAVA中提取此結果。下面有錯誤:JSON轉換結果在Java失敗(JSONObject無法轉換爲JSONArray)
Error converting result org.json.JSONException: Value
{"3":[{"date":"25\/07\/2011","descr":"Une colloque bla bla","numColloque":"1","titre":"Une colloque"}],
"2":[{"mail":"[email protected]","descr":"truc truc","nom":"Une personne","tel":"0600000000","numPersonne":"1"}],
"1":[{"lien":"http:\/\/www.irdes.fr","numTypeActu":"1","date":"25\/07\/2011","titre":"Une actualité récente","numActu":"1"}],
"7":[{"numEtablissement":"1","specialite":"STG","mention":"une mention","modalite":"BTS","titre":"Un titre de formation","numFormationCours":"1"}],
"6":[{"numEtablissement":"1","numEnseignement":"1","titre":"Cours de bla bla","numEnseignant":"1"}],
"5":[{"date":"31\/07\/2011","descr":"Université paris descartes dans le 1-ème arrondissement de Paris","numEtablissement":"1","libelle":"IUT Paris DESCARTES"}],
"4":[{"numDocument":"1","lienPDF":"http:\/\/www.irdes.com","date":"25\/07\/2011","numTypeDocument":"1","descrRapide":"un glossaire qui regroupe du bla bla","nom":"un document de glossaire"},
{"numDocument":"2","lienPDF":"http:\/\/www.irdes.com","date":"25\/07\/2011","numTypeDocument":"2","descrRapide":"Une synthèse parlant d'un truc","nom":"Une synthèse"}],
"9":[{"lien":"http:\/\/www.irdes.fr","descr":"un séminaire sur le blabla","date":"25\/07\/2011","heure":"14h30","nom":"Un séminaire","numSeminaire":"1"}],
"8":[{"numPublication":"1","lienPDF":"http:\/\/www.irdes.com","date":"25\/07\/2011","numTypePublication":"1","titre":"Une publication"},
{"numPublication":"2","lienPDF":"http:\/\/www.irdes.com","date":"25\/07\/2011","numTypePublication":"2","titre":"un titre de publication"},
{"numPublication":"3","lienPDF":"http:\/\/www.irdes.com","date":"25\/07\/2011","numTypePublication":"3","titre":"un titre"}]}
of type org.json.JSONObject cannot be converted to JSONArray
我結果的語法很簡單:
{"Object1":[{"id":"value"},{"id":"value"}],
"Object2":[{"id":"value"},{"id":"value"}],
...
}
我對提取JAVA腳本(LIGNE錯誤:有**):
result=sb.toString();
**JSONArray jArray = new JSONArray(result);**
for (int i=1;i<=9;i++){
JSONObject typeUpdateObject = jArray.getJSONObject(i);
extraction(typeUpdateObject, i);
}
這不是這種提取的正確方法嗎?
感謝您的代碼馬特:)只是爲第二個,它是j變量:)(j
toshiro92
感謝您的區別! –