ciao!
sto cercando di leggere dei dati in JSON in una servlet.
questi stessi identici dati li uso anche in una appa per android senza problemi.
nella servlet ho messo questo:
ma ottengo questo errore:codice:public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { String strUrl = "..............."; BufferedReader buff = new BufferedReader(new InputStreamReader(new URL(strUrl).openStream())); StringBuilder sb = new StringBuilder(); String str; while ((str = buff.readLine()) != null) { sb.append(str).append("\n"); } String strJson = sb.toString(); try { JSONObject jObj = new JSONObject(strJson); resp.getWriter().println(jObj.get("nome")); } catch (JSONException e) { resp.getWriter().println(e.getMessage()); } }
l'erroe è comprensibile, ma mi chiedo perchè su android non ho problemi.codice:A JSONObject text must begin with '{' at character 1 of [{"id":"35","nome":"abbonamenti riviste"},....................
anche la ho usato JSONObject.

Rispondi quotando
