Code example for JSONArray

Methods: isNulloptString

0
    public static String stringOrNull(JSONObject config, String string, String nullObj) {
        return config.isNull(string) ? nullObj : config.optString(string, nullObj);
    } 
 
    public static String stringOrNull(JSONArray array, int index, String nullObj) {
        return array.isNull(index) ? nullObj : array.optString(index);
    } 
 
	/** 
	 * Based on Apache Common Lang 2.6 implementation of StringEscapeUtls.escapeJavaScript. 
	 *  
	 * Future: Use JSONStringer? 
	 *  
	 * @param str The string to escape 
	 * @return Escaped string 
	 * @throws IOException 
	 */ 
	public static String escapeJavaScript(String str) {
		if (str == null) {
	        return null; 
	    }