How to convert web URL data to JSON format
I am mobile application developer. I want to try to get web URL data in JSON format. I have try to build image aggregator application.
I am trying this URL data in JSON format like our REST API response. Is it possible to convert JSON data of this URL.
I have also knowledge of Django framework. If it is not possible from front end using android studio then please share me possibility of Django.
Thank you
Try:
import com.google.gson.JsonObject;
import java.net.URLDecoder;
public JsonObject getJson(String url) {
try {
String queryString = url.split("\\?")[1];
String[] members = queryString.split("&");
JsonObject json = new JsonObject();
for (String member : members) {
String key = URLDecoder.decode(member.split("=")[0], "UTF-8");
String value = URLDecoder.decode(member.split("=")[1], "UTF-8");
json.addProperty(key, value);
}
return json;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}