How to parse below json response
{
"device": "thane1",
"sensor": "arduino",
"data": {
"1467871629": 303,
"1467871661": 303,
"1467871693": 303,
"1467871720": 303,
"1467871755": 303,
"1467871785": 303,
"1467871807": 303,
"1467886625": 326,
"1467886659": 327,
"1467886692": 326,
"1467886725": 326,
"1467886858": 326
}
}
Code used:
private class getChartData extends AsyncTask<String, Void, String> {
protected String doInBackground(String... params) {
return getData();
}
protected String getData() {
String decodedString = "";
String returnMsg = "";
String request = "http://52.77.220.93:4000/getLast?device=thane1&sensor=arduino&lim=300";
URL url;
HttpURLConnection connection = null;
try {
url = new URL(request);
connection = (HttpURLConnection) url.openConnection();
connection.addRequestProperty("Content-Type", "application/json");
connection.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
//parsing here
}