Tecnologia do Blogger.
RSS

[androidbrasil-dev] Parsing usando a lib OKHttp

Olá Pessoal,

Alguém poderia me dar uma dica, por que não estou conseguindo fazer o parsing usando a lib OKHttp, esse é meu retorno do Json

http://localhost:8089/REST/PRODUTOS?CODPRODUTO=032900301 {"_classname":"PRODUTOS","CODIGO":"032900301 ","DESCRICAO":"MARCADOR P\/ QUADRO BRANCO VERM","MEDIDA":"PC","PRECO":42.99,"SITUACAO":"ATIVO"}
{
    "_classname": "PRODUTOS",
    "CODIGO": "032900301      ",
    "DESCRICAO": "MARCADOR P/ QUADRO BRANCO VERM",
    "MEDIDA": "PC",
    "PRECO": 42.99,
    "SITUACAO": "ATIVO"
}


private void getWebservice(){      //pega os valores dos edittexto      final String codprod = editText.getText().toString();        final Request request = new Request.Builder().url("http://192.168.0.120:8089/REST/PRODUTOS?CODPRODUTO="+codprod).build();            OkHttpClient client = new OkHttpClient();            client.newCall(request).enqueue(new Callback() {          @Override          public void onFailure(Call call, IOException e) {              runOnUiThread(new Runnable() {                  @Override                  public void run() {                      result.setText("Falha de conexão");                    }              });          }            @Override          public void onResponse(Call call, final Response response) throws IOException  {                //final String myResponse = response.body().string();              runOnUiThread(new Runnable() {                  @Override                  public void run() {                      try {                            result.setText(response.body().string());                          //codigo.setText(response.body().string());                        }catch (IOException ioe){                          result.setText("Erro chamada do body ");                      }                  }              });          }      });        }        public void getWebserviceoh(){          JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(com.android.volley.Request.Method.GET, url, null, new com.android.volley.Response.Listener<JSONObject>() {              @Override              public void onResponse(JSONObject response) {                  try {                      CODIGO = response.getString("CODIGO");                      DESCRICAO = response.getString("DESCRICAO");                      MEDIDA = response.getString("MEDIDA");                      PRECO = response.getString("PRECO");                      SITUACAO = response.getString("SITUACAO");                        codigoText.setText("CODIGO");                      descricaoText.setText("DESCRICAO");                      medidaText.setText("MEDIDA");                      precoText.setText("PRECO");                      situacaoText.setText("SITUACAO");                    } catch (JSONException e) {                      e.printStackTrace();                  }                }          }, new com.android.volley.Response.ErrorListener() {              @Override              public void onErrorResponse(VolleyError error) {                }          });           rq.add(jsonObjectRequest);      }  }  

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário