Utilities to make saving and loading in Processing more convenient.
In Processing, to save an array of floating points, xs, to a JSONObject, json, you would typically write something like:
JSONArray js = new JSONArray();
for (int i=0; i<xs.length; i++) {
js.setFloat(i, xs[i]);
}
json.setJSONArray("xs", js);
With this library, you can instead write:
json.setJSONArray("xs", Util.jsonify(xs));
To load an array of floating points from a JSONObject, you would typically write something like this:
JSONArray js = json.getJSONArray("xs");
float[] xs = new float[js.size()];
for (int i=0; i<js.size(); i++) {
xs[i] = js.getFloat(i);
}
With this library, you can instead write:
float[] xs = Util.toFloatArray(json.getJSONArray("xs"));