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
Carefully see your code
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
// return JSON String
return jObj;
In above case if you get any JSONException then you are returning jObj which is not initialized,in short you will return null jObj.
So you much handle that situation by checking if returned object is null.
change your code to following
if (jon != null)
{
String id = jon.getString("status");
Toast.makeText(getApplicationContext(), id, Toast.LENGTH_LONG).show();
}