Loads a JSON from the data folder or a URL, and returns a JSONObject . All files loaded and saved by the Processing API use UTF-8 encoding. @webref input:files @webBrief Loads a JSON from the data folder or a URL, and returns a JSONObject @param filename
(String filename)
| 5365 | * @see PApplet#saveJSONArray(JSONArray, String) |
| 5366 | */ |
| 5367 | public JSONObject loadJSONObject(String filename) { |
| 5368 | // can't pass of createReader() to the constructor b/c of resource leak |
| 5369 | BufferedReader reader = createReader(filename); |
| 5370 | if (reader != null) { |
| 5371 | JSONObject outgoing = new JSONObject(reader); |
| 5372 | try { |
| 5373 | reader.close(); |
| 5374 | } catch (IOException e) { // not sure what would cause this |
| 5375 | e.printStackTrace(); |
| 5376 | } |
| 5377 | return outgoing; |
| 5378 | } |
| 5379 | return null; |
| 5380 | } |
| 5381 | |
| 5382 | |
| 5383 | /** |
nothing calls this directly
no test coverage detected