When my return Json is an array how can I get this array?

Asked

Viewed 71 times

1

try{
                    URL urlConection = new URL(caminho);
                    conn = (HttpURLConnection) urlConection.openConnection();
                    conn.setDoOutput(true);
                    conn.setRequestMethod("POST");

                   /* DataOutputStream pt = new DataOutputStream(conn.getOutputStream());
                    pt.writeBytes(obj.toString());*/

                    PrintStream ps = new PrintStream(conn.getOutputStream());
                    ps.printf("json", obj.toString());

                    conn.connect();

                    //String resposta = decodifica(new String[]{new Scanner(conn.getInputStream()).next()});
                    String resposta = new Scanner(conn.getInputStream()).next();
                    Log.d("teste", obj.toString());

                    if(resposta.equals("1")){
                        Intent abreHome = new Intent(Login.this, Home.class);
                        startActivity(abreHome);
                    } else {
                        Toast.makeText(Login.this, "Ops houve um erro. Tente novamente", Toast.LENGTH_SHORT).show();
                        Log.d("retorno", resposta);
                    }


                } catch (MalformedURLException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
  • 1

    See if it’s this or this looking for.

  • 1

    You can show an example of this JSON?

  • My return from php webservice is an encode_json the returned data is: {"User":{"id":"1","status_id":"1","name":"Felipe Botelho","RA":"242252014","email":"[email protected]","password":"123456","data_cancel":null},"Status":{"id":"1","name":"Active"}}

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.