package me.jacobcrofts.simplestructureloader.api;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;

import me.jacobcrofts.simplestructureloader.util.Selection;

public final class StructureAPI {
	
	private StructureAPI() {}
	
	public static void writeToFile(String path, Selection selection) throws IOException {
		FileWriter writer = new FileWriter(path);
		writer.write(selection.toJSON().toJSONString());
		writer.close();
	}
	
//	playerData = (JSONObject) new JSONParser().parse(new FileReader(f));

}

@@ -44,16 +44,54 @@
 r.api;%0A%0A
+import java.io.FileNotFoundException;%0A
 import j
@@ -105,24 +105,24 @@
 FileReader;%0A
-
 import java.
@@ -192,22 +192,21 @@
 ple.JSON
-Object
+Array
 ;%0Aimport
@@ -240,16 +240,62 @@
 NParser;
+%0Aimport org.json.simple.parser.ParseException;
 %0A%0Aimport
@@ -623,35 +623,138 @@
 %7D%0A%09%0A
-//%09playerData = (JSONObject
+%09public static JSONArray readFromFile(String path) throws FileNotFoundException, IOException, ParseException %7B%0A%09%09return (JSONArray
 ) ne
@@ -793,12 +793,19 @@
 der(
-f));%0A
+path));%0A%09%7D%0A%09
 %0A%7D%0A

Add feature: API reads JSON from file