|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
package org.xbib.datastructures.json.tiny.test;
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
import org.xbib.datastructures.json.tiny.TinyJsonListener;
|
|
|
|
|
import org.xbib.datastructures.json.tiny.StreamParser;
|
|
|
|
|
import org.xbib.datastructures.json.tiny.StringParser;
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
@ -20,9 +19,10 @@ public class ParserTest {
|
|
|
|
|
if (inputStream != null) {
|
|
|
|
|
byte[] b = inputStream.readAllBytes();
|
|
|
|
|
String string = new String(b, StandardCharsets.UTF_8);
|
|
|
|
|
StringParser stringParser = new StringParser(new TinyJsonListener());
|
|
|
|
|
StringParser stringParser = new StringParser();
|
|
|
|
|
stringParser.parse(string);
|
|
|
|
|
assertEquals("{a=b, c=d, e=[f, g], h={i={j=k}}, l=null, m=true, n=false, o=0, p=1, q=-1, r=0.0, s=1.0, t=2.1, u=-1.0, v=-2.1, w=, x=₫, y=Jörg}",
|
|
|
|
|
assertEquals("{a=b, c=d, e=[f, g], h={i={j=k}}, l=null, m=true, n=false, o=0, p=1, q=-1, r=0.0, s=1.0, t=2.1, u=-1.0, v=-2.1, w=, x=₫, y=Jörg, z=This is \"quoted\" text\n" +
|
|
|
|
|
"after line break}",
|
|
|
|
|
stringParser.getNode().get().toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -33,8 +33,10 @@ public class ParserTest {
|
|
|
|
|
InputStream inputStream = ParserTest.class.getResourceAsStream("/org/xbib/datastructures/json/tiny/test/test.json");
|
|
|
|
|
if (inputStream != null) {
|
|
|
|
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
|
|
|
|
|
StreamParser streamParser = new StreamParser(new TinyJsonListener());
|
|
|
|
|
assertEquals("{a=b, c=d, e=[f, g], h={i={j=k}}, l=null, m=true, n=false, o=0, p=1, q=-1, r=0.0, s=1.0, t=2.1, u=-1.0, v=-2.1, w=, x=₫, y=Jörg}", streamParser.parse(reader).get().toString());
|
|
|
|
|
StreamParser streamParser = new StreamParser();
|
|
|
|
|
assertEquals("{a=b, c=d, e=[f, g], h={i={j=k}}, l=null, m=true, n=false, o=0, p=1, q=-1, r=0.0, s=1.0, t=2.1, u=-1.0, v=-2.1, w=, x=₫, y=Jörg, z=This is \"quoted\" text\n" +
|
|
|
|
|
"after line break}",
|
|
|
|
|
streamParser.parse(reader).get().toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|