Please could you give me a hand here, I am trying to parse a JSON file from a URL. Below is the code that i used to grab the file and initially just posted it to a TextView but now I want to parse the tags and use them?
private void postData(final String param, final TextView tv) {
final RequestQueue request = Volley.newRequestQueue(this);
JSONObject postReq = new JSONObject(Request.Method.GET, url_login, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
System.out.println("Error [" + error + "]");
}
}) {
@Override
public Map getHeaders() throws AuthFailureError {
Map headers = new HashMap();
headers.put("Accept", "application/json");
System.out.println(headers);
return headers;
}
};
request.add(postReq);
}
an example of the JSON is below
{
“UserInfo”: {
“User”: {
“name”: “Craig”,
“surname”: "Churchill",
"userId": "1463353",
"userAlias": "Craig"
}
}
}
I have tried this but have just failed constantly and just cannot get it right.