Murtaza Murtaza - 1 month ago 9
JSON Question

How to change URL from JSON parsing

hi guys i am making an Android app which enlarge the Instagram profile pictures
i have done everything correctly now what i want is to modifiy the output url that i am getting from instagram server for example when i run my json script it give me this

and i want to convert this to that

here is my code that i am using

final JsonObjectRequest jsonRequest = new JsonObjectRequest(Request.Method.GET, finalURL, null, new Response.Listener<JSONObject>() {
public void onResponse(JSONObject response) {

try {

JSONObject user = response.getJSONObject("user");
String profilePicture = user.getString("profile_pic_url_hd");

Log.v("JSON", "User: " + profilePicture);
} catch (JSONException e) {


}, new Response.ErrorListener() {
public void onErrorResponse(VolleyError error) {

Log.v("FUN", "Error " + error.toString());



Answer Source

Try this:

String imageUrl=originalUrl.replaceAll("[s][0-9]+[x][0-9]+","s"+desiredWidth+"x"+desiredHeight);