Skip to content

Commit facf00d

Browse files
committed
2.0.0 JSONTestSuite results added
1 parent 4b7957c commit facf00d

File tree

8 files changed

+59
-0
lines changed

8 files changed

+59
-0
lines changed

JSONTestSuite/README

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
See: https://github.com/nst/JSONTestSuite
2+
IMHO some of the claims of this test are debatable
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Main-Class: TestJSONParsing
3+
Class-Path: json-2.0.0.jar
Binary file not shown.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// javac -cp ".:json-2.0.0.jar" TestJSONParsing.java && java -classpath ".:json-2.0.0.jar" TestJSONParsing x.json
2+
3+
import java.io.IOException;
4+
import java.nio.file.Files;
5+
import java.nio.file.Paths;
6+
import java.text.ParseException;
7+
import org.miktim.json.JSON;
8+
9+
10+
public class TestJSONParsing {
11+
12+
public static boolean isValidJSON(String s) {
13+
try {
14+
Object obj = JSON.parse(s);
15+
// System.out.println(obj);
16+
// System.out.println(obj != null ? obj.getClass().getSimpleName() : null);
17+
return true;
18+
} catch (ParseException | IOException e) {
19+
// System.out.println(e);
20+
return false;
21+
}
22+
}
23+
24+
public static void main(String[] args) {
25+
26+
if(args.length == 0) {
27+
System.out.println("Usage: java TestJSONParsing file.json");
28+
System.exit(2);
29+
}
30+
31+
try {
32+
String s = new String(Files.readAllBytes(Paths.get(args[0])));
33+
if(isValidJSON(s)) {
34+
System.out.println("valid");
35+
System.exit(0);
36+
}
37+
System.out.println("invalid");
38+
System.exit(1);
39+
} catch (IOException e) {
40+
System.out.println("not found");
41+
System.exit(2);
42+
}
43+
}
44+
}
17.7 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
javac -cp ".:json-2.0.0.jar" TestJSONParsing.java
4+
jar cvfm TestJSONParsing.jar META-INF/MANIFEST.MF json-2.0.0.jar TestJSONParsing.class
5+
java -jar ./TestJSONParsing.jar

JSONTestSuite/run_tests.py.entry

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"Java miktim json 2.0":
2+
{
3+
"url":"https://github.com/miktim/JSON",
4+
"commands":["/usr/bin/java", "-jar", os.path.join(PARSERS_DIR, "test_java_miktim_json_2_0/TestJSONParsing.jar")]
5+
},

parsing.html

204 KB
Binary file not shown.

0 commit comments

Comments
 (0)