json
This commit is contained in:
@@ -162,7 +162,7 @@ public class JsonReader extends Reader {
|
||||
*/
|
||||
protected char nextChar() {
|
||||
int p = ++this.position;
|
||||
if (p >= limit) {
|
||||
if (p > limit) {
|
||||
return 0;
|
||||
}
|
||||
return this.text[p];
|
||||
|
||||
@@ -12,38 +12,38 @@ import org.redkale.convert.json.*;
|
||||
/** @author zhangjx */
|
||||
public class TinyTest {
|
||||
|
||||
private boolean main;
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
TinyTest test = new TinyTest();
|
||||
test.main = true;
|
||||
test.run();
|
||||
test.run1();
|
||||
test.run2();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void run() throws Exception {
|
||||
public void run1() throws Exception {
|
||||
TinyRecord record = new TinyRecord();
|
||||
record.id = 5;
|
||||
{
|
||||
JsonFactory factory = JsonFactory.create().withFeatures(Convert.FEATURE_TINY);
|
||||
JsonConvert convert = factory.getConvert();
|
||||
String json = "{\"id\":5}";
|
||||
if (!main) {
|
||||
Assertions.assertEquals(json, convert.convertTo(record));
|
||||
}
|
||||
Assertions.assertEquals(json, convert.convertTo(record));
|
||||
System.out.println(convert.convertTo(record));
|
||||
}
|
||||
{
|
||||
JsonFactory factory = JsonFactory.create().withFeatures(0);
|
||||
JsonConvert convert = factory.getConvert();
|
||||
String json = "{\"id\":5,\"name\":\"\"}";
|
||||
if (!main) {
|
||||
Assertions.assertEquals(json, convert.convertTo(record));
|
||||
}
|
||||
Assertions.assertEquals(json, convert.convertTo(record));
|
||||
System.out.println(convert.convertTo(record));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void run2() throws Exception {
|
||||
String json = "{\"id\":5,\"name\":\"\", \"status\":2}";
|
||||
JsonConvert.root().convertFrom(TinyRecord.class, json);
|
||||
}
|
||||
|
||||
public static class TinyRecord {
|
||||
|
||||
public String name = "";
|
||||
|
||||
Reference in New Issue
Block a user