Note that there are some explanatory texts on larger screens.

plurals
  1. POTo read the json as a string object in android
    primarykey
    data
    text
    <p>I have read JSON data from a URL as a string object and passed it (as a string object) to my second activity. How can I read values from this string object? Please help me.</p> <p>Below is my json:</p> <pre><code>{ "speciality": [ { "id": "1", "d_name": "Dr.Steven Cohen", "file_upload": "dr-photo.png", "d_address": "3838 California St. San Francisco,CA 94118", "d_specialty": "Eye", "designation": "Ophthalmologist", "d_city": "San Francisco", "d_state": "Calfornia", "d_zipcode": "CA94118", "d_phone": "018 000 000", "latitude": "18.815427", "longitude": "76.775144" }, { "id": "2", "d_name": "Dr. Hanish Patel", "file_upload": "hanish-patel.jpg", "d_address": " 160 East 56th Street New York, NY 10022 ", "d_specialty": "Eye", "designation": "Optometrist", "d_city": "New York", "d_state": "United States", "d_zipcode": "NY 10022", "d_phone": "018 000 000", "latitude": "40.760407", "longitude": "-73.968694" }, { "id": "3", "d_name": " Dr. Leonard Bley MD, FACS ", "file_upload": "leonard-bley.jpg", "d_address": " 160 East 56th Street New York, NY 10022", "d_specialty": "Eye", "designation": "Ophthalmologist", "d_city": "New York", "d_state": "United States", "d_zipcode": "NY 10022", "d_phone": "018 000 000", "latitude": "40.760407", "longitude": "-73.968694" }, { "id": "4", "d_name": "Dr. John Selle", "file_upload": "john_selle.jpg", "d_address": "2250 Hayes St Ste 206 San Francisco, CA 94117", "d_specialty": "Eye", "designation": "General Practitioner", "d_city": "San Francisco", "d_state": "Calfornia", "d_zipcode": "CA94118", "d_phone": "018 000 000", "latitude": "37.78604", "longitude": "-122.457639" } ] } </code></pre> <p>And here is my code:</p> <pre><code>try { JSONObject mainObject = new JSONObject(strjson); //JSONObject uniObject = mainObject.getJSONObject("speciality"); //JSONObject uniName = uniObject.getJSONObject("d_name"); //JSONObject uniURL = uniObject.getJSONObject("d_address"); JSONObject oneObject = mainObject.getJSONObject("d_name"); Log.e("name:", "unique name" + oneObject); } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } </code></pre> <p>}</p>
    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.
 

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