Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this..</p> <p>if your <code>json</code> is like this </p> <pre><code>{"id":"OFF","TAG_EMAIL":"OFF","name":"OFF"} </code></pre> <p>then </p> <p>you can check whether that tag name present or not </p> <pre><code>System.out.println("JSON Response : "+json.toString().trim()); if(json.has("id")) String id = json.getString("id"); if(json.has("name")) String name = json.getString("name"); if(json.has("TAG_EMAIL")) String email = json.getString("TAG_EMAIL"); </code></pre> <p><strong>EDIT:</strong></p> <p>your parsing like below</p> <pre><code>user = json.getJSONArray(TAG_USER); </code></pre> <p>there is no <code>JSONArray</code> only <code>JSONObject</code> so you cannot parse <code>JSONObject</code> as <code>JSONArray</code> then there is no <code>user</code> as <code>JSONArray</code></p> <p><strong>EDIT 1 :</strong></p> <pre><code>try { System.out.println("JSON Response : "+json.toString().trim()); if(json.has("id")) String id = json.getString("id"); if(json.has("name")) String name = json.getString("name"); if(json.has("TAG_EMAIL")) String email = json.getString("TAG_EMAIL"); //Set JSON Data in TextView uid.setText(id); name1.setText(name); email1.setText(email); } catch (JSONException e) { e.printStackTrace(); } </code></pre> <p><strong>EDIT 2:</strong></p> <pre><code>try { System.out.println("JSON Response : "+json.toString().trim()); JSONObject c = json.getJSONObject("TAG_USER"); if(c.has("id")) String id = c.getString("id"); if(c.has("name")) String name = c.getString("name"); if(c.has("TAG_EMAIL")) String email = c.getString("TAG_EMAIL"); //Set JSON Data in TextView uid.setText(id); name1.setText(name); email1.setText(email); } catch (JSONException e) { e.printStackTrace(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload