Code example for JSONException

0
        JSONTokener t = new JSONTokener(s);
        Object o = t.nextValue();
        if (o instanceof JSONObject) {
            return (JSONObject) o;
        } else { 
            throw new JSONException(s + " couldn't be parsed as JSON object");
        } 
    } 
 
    static public JSONArray evaluateJsonStringToArray(String s) throws JSONException {
        JSONTokener t = new JSONTokener(s);
        Object o = t.nextValue();
        if (o instanceof JSONArray) {
            return (JSONArray) o;
        } else { 
            throw new JSONException(s + " couldn't be parsed as JSON array");
        } 
    } 
 
    private static final URLCodec codec = new URLCodec();
Stop searching for code, let great code find you!  Add Codota to your java IDE