mysql ve android JSON hatası

Kolay gelsin.Bir android,mysql projem var ve kayıt yaptırmaya çalışıyorum.value br of type java.lang.string cannot be converted to jsonobject android.Böyle bir hata alıyorum.Nedendir?Ve çözümü nedir?

SadıkKaplan

Cum, 07/12/2018 - 20:36
Merhaba ilk olarak Json verisi %100 doğru formatta verilmemiş ve okumada bir şey kaçırıyor olabilirsin. Parantezleri virgülleri dizi parantezlerini iyi kontrol edin. Arkadaşın yazdığı gibi response değerinde sorun olabilir debug modda ya da kısım kısım try-catch koyarak hatayı tespit edebilirsin.

    -1

    berna koç

    05 Aralık 2018

    JSONObject jsonObject=new JSONObject(response); String success= jsonObject.getString("success"); if(success.equals("1")){ Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show(); } } catch (JSONException e){ e.printStackTrace(); Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); }  

    0

    berna koç

    05 Aralık 2018

    JSONObject jsonObject=new JSONObject(response); String success= jsonObject.getString("success"); if(success.equals("1")){ Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show(); } } catch (JSONException e){ e.printStackTrace(); Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); }  

    0

    berna koç

    05 Aralık 2018

    JSONObject jsonObject=new JSONObject(response); String success= jsonObject.getString("success"); if(success.equals("1")){ Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show(); } } catch (JSONException e){ e.printStackTrace(); Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); }  

    0

    berna koç

    05 Aralık 2018

    JSONObject jsonObject=new JSONObject(response); String success= jsonObject.getString("success"); if(success.equals("1")){ Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show(); } } catch (JSONException e){ e.printStackTrace(); Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); }  

    0

    Emre Kaplan

    Android Developer at Nevitech - 05 Aralık 2018

    Merhaba, şu şekilde bir kod parçası var. JSONObject obj = new JSONObject(stringData); burada ki stringData'nın formatı json' a dönüştürülemiyor. Kullandığın web servisi dışarıdan çağırarak geriye dönen datayı incele sorunu çözersin. Kolay gelsin.

      bernaelif06

      Çar, 05/12/2018 - 11:37
      Sorun şu ki ne yapacağımı bilmiyorum.İnternetten denilen herşeyi denedim ama olmadı.Yardımcı olursanız sevinirim.

    0

    berna koç

    05 Aralık 2018

      public void onResponse(String response) { try{ final JSONObject jsonObject=new JSONObject(response); String success= jsonObject.getString("success"); if(success.equals("1")){ Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show(); } } catch (JSONException e){ e.printStackTrace(); Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); } })  

    0

    berna koç

    05 Aralık 2018

    public void onResponse(String response) { try{ final JSONObject jsonObject=new JSONObject(response); String success= jsonObject.getString("success"); if(success.equals("1")){ Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show(); } } catch (JSONException e){ e.printStackTrace(); Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); } })   public void onResponse(String response) { try{ final JSONObject jsonObject=new JSONObject(response); String success= jsonObject.getString("success"); if(success.equals("1")){ Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show(); } } catch (JSONException e){ e.printStackTrace(); Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); } })  

    0

    berna koç

    05 Aralık 2018

    JSONObject jsonObject=new JSONObject(response); String success= jsonObject.getString("success"); if(success.equals("1")){ Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show(); } } catch (JSONException e){ e.printStackTrace(); Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); }  

    0

    Emre Kaplan

    Android Developer at Nevitech - 05 Aralık 2018

    response değerinde sıkıntı var galiba. bu satıra breakpoint koyarak debug modda bakabilir misin ? response içeriğini görmüş oluruz. 

    0

    berna koç

    05 Aralık 2018

    JSONObject jsonObject=new JSONObject(response); String success= jsonObject.getString("success"); if(success.equals("1")){ Toast.makeText(RegisterActivity.this,"register success",Toast.LENGTH_SHORT).show(); } } catch (JSONException e){ e.printStackTrace(); Toast.makeText(RegisterActivity.this,"register error"+e.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(RegisterActivity.this,"register error"+error.toString(),Toast.LENGTH_SHORT).show(); loading.setVisibility(View.GONE); btn_regist.setVisibility(View.VISIBLE); }  

    Bu soruya cevap vermek için üye olmanız veya giriş yapmanız gerekmektedir.