anthebest Posted September 23, 2012 Share Posted September 23, 2012 Bonjour. je n'arrive pas à parser un doc en json. mon doc ressemble à ça: [{"id":"1","nom","jean"},{"id":"2","nom":"paul"}] Mais je n'arrive pas trop a trouver comment le transformer en tableau. par exemple en javascript c'est simple il y a juste JSON.parse j'ai essayé mais sans trop de succès public JSONObject parseJson() throws JSONException{ JSONObject jsonObject = new JSONObject(html); return jsonObject; } a chaque fois l'erreur est levée (html est mon json en string) Pourriez vous m'aider ?? Merci :) Edit: j'ai trouvé :) JSONArray jsonRootArray = new JSONArray (“[{"id":"1","nom","jean"},{"id":"2","nom":"paul"}]”); for (int i = 0; i < jsonRootArray.length(); i++) { JSONObject jsonObj = jsonRootArray.getJSONObject(i); String strId = jsonObj.getString("id"); String strName = jsonObj.getString("nom"); } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.