mirror of
https://github.com/processing/processing4.git
synced 2026-02-05 06:39:20 +01:00
save methods for JSON objects and arrays
This commit is contained in:
@@ -34,12 +34,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import processing.core.PApplet;
|
||||
|
||||
/**
|
||||
* A JSONArray is an ordered sequence of values. Its external text form is a
|
||||
* string wrapped in square brackets with commas separating the values. The
|
||||
@@ -847,6 +852,22 @@ public class JSONArray {
|
||||
// }
|
||||
|
||||
|
||||
protected boolean save(OutputStream output) {
|
||||
return save(PApplet.createWriter(output));
|
||||
}
|
||||
|
||||
|
||||
public boolean save(File file, String options) {
|
||||
return save(PApplet.createWriter(file));
|
||||
}
|
||||
|
||||
|
||||
public boolean save(PrintWriter output) {
|
||||
output.print(format(2));
|
||||
output.flush();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the JSON data formatted with two spaces for indents.
|
||||
|
||||
Reference in New Issue
Block a user