@@ -0,0 +1,40 @@
1+import java.nio.charset.StandardCharsets;
2+import java.io.IOException;
3+import java.nio.file.Files;
4+import java.nio.file.Paths;
5+
6+import com.leastfixedpoint.json.*;
7+
8+public class TestJSONParsing {
9+ public static boolean isValidJSON(String s) {
10+ try {
11+ Object obj = JSONReader.readFrom(s);
12+ System.out.println(obj);
13+ System.out.println(obj.getClass().getSimpleName());
14+ return true;
15+ } catch (IOException e) {
16+ System.out.println(e);
17+ return false;
18+ }
19+ }
20+
21+ public static void main(String[] args) {
22+ if(args.length == 0) {
23+ System.out.println("Usage: java TestJSONParsing file.json");
24+ System.exit(2);
25+ }
26+
27+ try {
28+ String s = new String(Files.readAllBytes(Paths.get(args[0])));
29+ if(isValidJSON(s)) {
30+ System.out.println("valid");
31+ System.exit(0);
32+ }
33+ System.out.println("invalid");
34+ System.exit(1);
35+ } catch (IOException e) {
36+ System.out.println("not found");
37+ System.exit(2);
38+ }
39+ }
40+}