So I'm working with returned values from a JSON object and I'm trying to return the values of one of its keys. So the JSON object I get is this.
{"options":[{"picture":"http:\/\/example.com\/1.png", contact_id="1", name="Tom"}, {"picture":"http:\/\/example.com\/2.png", contact_id="2", name="Jess"}]}
Now I'm handling it in an android app and when I have a final static String called say TAG which is set to options
private static final String TAG = "options";
and I use to log the json values like this
Log.d("Friends name", jsn.getString(TAG));
I get the first result
{"options":[{"picture":"http:\/\/example.com\/1.png", contact_id="1", name="Tom"}, {"picture":"http:\/\/example.com\/2.png", contact_id="2", name="Jess"}]}
However I'm trying to access the names only and I don't really know how to.
I tried setting TAG to options[0].name to get just the first name but it gave me an error
JSONException : No Value for options[0].name
I'm a bit lost here.
jsn.options[0].name;In the case of yours -TAG = jsn.options[0].name;.