Code example for JSONTokener

Methods: back, next

0
        return tree.getResult();
    } 
 
    private static void buildJsonX(TreeWriter tree, JSONTokener jt) {
        try { 
            char ch = jt.next();
            jt.back();
 
            if (ch == '{') {
                tree.addStartElement(j_object);
                tree.startContent();
                buildJsonXPairs(tree, new JSONObject(jt));
            } else { 
                tree.addStartElement(j_array);
                buildJsonXArray(tree, new JSONArray(jt));
            } 
        } catch (JSONException je) {
            throw new XProcException(je);
        } 
 
        tree.addEndElement();