Java tutorial
//package com.java2s; import android.util.Log; import org.json.JSONException; import org.json.JSONObject; public class Main { public static final String TAG = "ForecastApiUtils"; private static int getNullCheckInt(JSONObject o, String value) { try { if (o.isNull(value)) { return -1; } else { return o.getInt(value); } } catch (JSONException je) { Log.e(TAG, "Failed to parse JSON", je); } return 0; } }