Code example for JSONObject

Methods: getInt

0
        } 
    } 
 
    private static int getSafeInt(JSONObject json, String key ) {
        try { 
            return json.getInt(key);
        } catch (Exception e) {
            return 0; 
        } 
    } 
 
    public static String[] getStringArray(JSONObject aObject, String aName) {
        JSONArray items = getSafeArray(aObject, aName);
        int length = items.length();
        String[] list = new String[length];
        for (int i = 0; i < length; i++) {
            try { 
                list[i] = items.getString(i);
            } catch(Exception ex) { }
        } 
        return list;