Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Jsp (server)
- String xCatalogo = request.getParameter("xCatalogo");
- String xdburl = request.getParameter("xUrl");
- String xdbuser = request.getParameter("xUser");
- String xdbpass = request.getParameter("xPass");
- conexion con = new conexion(xdburl, xdbuser, xdbpass);
- ResultSet rs1;
- int xResultado = 0;
- JSONObject json = new JSONObject();
- String qry = "";
- String whtml2 = "";
- // ArrayList<String> catalog = new ArrayList<String>();
- if (xCatalogo.equals("cFrigorificos")) {
- qry = "select * from tcatfrigo where icatfrigostatus=1 order by icatfrigoorden";
- rs1 = con.consulta(qry);
- List<catFrigorifico> listacatFrigorificos = new ArrayList<catFrigorifico>();
- if (rs1.next()) {
- xResultado = 1;
- rs1.beforeFirst();
- while (rs1.next()) {
- catFrigorifico xFrigo = new catFrigorifico(rs1.getInt("icatfrigoid"), rs1.getString("ccatfrigocodigo"), rs1.getString("ccatfrigonombre"), rs1.getInt("icatfrigoorden"));
- listacatFrigorificos.add(xFrigo);
- // catalog.add(rs1.getInt("icatfrigoid") + "|" + rs1.getString("ccatfrigocodigo") + "|" + rs1.getString("ccatfrigonombre") + "|" + rs1.getInt("icatfrigoorden"));
- }
- }
- // json.put("xListaCatalogosFrigorificos", catalog);
- json.put("xListaCatalogosFrigorificos", listacatFrigorificos);
- }
- json.put("xResultado", xResultado);
- out.println(json);
- out.flush();
- //Android (client)
- try {
- //Creating JsonObject from response String
- JSONObject jsonObject = new JSONObject(response.toString());
- Log.v("JSONParser", "response: " + response.toString());
- //extracting json array from response string
- JSONArray jsonArray = jsonObject.getJSONArray("xListaCatalogosFrigorificos");
- for (int i=0; i<jsonArray.length(); i++){
- JSONObject json_data = jsonArray.getJSONObject(i);
- json_data = json_data;
- }
- } catch (JSONException e) {
- Log.i("tag", "error Json " + e.getMessage());
- }
- the problem is in Android Part in this line:
- JSONObject json_data = jsonArray.getJSONObject(i);
- throw a exception and is:
- "Value beans.catFrigorifico@15aa13f7 at 0 of type java.lang.String cannot be converted to JSONObject"
- how to fix?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement