Code example for JSONTokener

Methods: nextValue

     * Parses JSON and creates an object. 
     * @return The resulting object which may be a List,  
     * Map, Number, String, Boolean, or null 
    public Object read() throws JSONException {
        JSONTokener tk = new JSONTokener(json);
        try { 
            return readSubObject(tk.nextValue());
        } catch(org.json.JSONException e) {
            throw new JSONException(e.toString());
     * Assumes that a JSON array will be read.  Returns 
     * the resulting array as a list. 
    public List<?> readArray() throws JSONException {
        Object o = read();
        try { 
Experience pair programming with AI  Get Codota for Java