I am new to JSON. I am using http://pnrapi.appspot.com/ to get the status of a particular train using JSON. But while trying to parse the received object i always get a null poi
use get instead of getString as:
try {
JSONObject jsona=new JSONObject("{'status': 'INVALID', 'data': 'No results'}");
String id = (String)jsona.get("status");
Toast.makeText(DfgdgdfgdfActivity.this, id, Toast.LENGTH_LONG).show();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
EDIT:
use
while ((line = reader.readLine()) != null) {
sb.append(line);
}
instead of
while ((line = reader.readLine()) != null) {
sb.append(line + "n");
}