diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 1233df3da..d80a33c34 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -6028,6 +6028,7 @@ public class PApplet extends Applet } } + /** * @webref input:files * @param filename name of a file in the data folder or a URL. @@ -6043,6 +6044,7 @@ public class PApplet extends Applet return loadXML(filename, null); } + // version that uses 'options' though there are currently no supported options /** * @nowebref @@ -6056,6 +6058,7 @@ public class PApplet extends Applet } } + /** * @webref input:files * @brief Converts String content to an XML object @@ -6070,6 +6073,7 @@ public class PApplet extends Applet return parseXML(xmlString, null); } + public XML parseXML(String xmlString, String options) { try { return XML.parse(xmlString, options); @@ -6079,6 +6083,7 @@ public class PApplet extends Applet } } + /** * @webref output:files * @param xml the XML object to save to disk @@ -6104,6 +6109,12 @@ public class PApplet extends Applet } + public JSONArray loadJSONArray(String filename) { + JSONTokener tokener = new JSONTokener(createReader(filename)); + return new JSONArray(tokener); + } + + /** * @webref input:files * @see Table @@ -6884,8 +6895,9 @@ public class PApplet extends Applet File file = new File(dataPath(filename)); if (!file.exists()) { // next see if it's just in the sketch folder - file = new File(sketchPath, filename); + file = sketchFile(filename); } + if (file.isDirectory()) { return null; } diff --git a/core/src/processing/data/JSONArray.java b/core/src/processing/data/JSONArray.java index 618c7c60a..c195065e5 100644 --- a/core/src/processing/data/JSONArray.java +++ b/core/src/processing/data/JSONArray.java @@ -107,7 +107,7 @@ public class JSONArray { * @param x A JSONTokener * @throws JSONException If there is a syntax error. */ - protected JSONArray(JSONTokener x) { + public JSONArray(JSONTokener x) { this(); if (x.nextClean() != '[') { throw new RuntimeException("A JSONArray text must start with '['"); @@ -332,7 +332,7 @@ public class JSONArray { * @throws JSONException If there is no value for the index. or if the * value is not a JSONArray */ - public JSONArray getArray(int index) { + public JSONArray getJSONArray(int index) { Object object = this.get(index); if (object instanceof JSONArray) { return (JSONArray)object; @@ -348,7 +348,7 @@ public class JSONArray { * @throws JSONException If there is no value for the index or if the * value is not a JSONObject */ - public JSONObject getObject(int index) { + public JSONObject getJSONObject(int index) { Object object = this.get(index); if (object instanceof JSONObject) { return (JSONObject)object;