修复json在ByteBuffer、InputSteam参数下无法解决数组的问题

This commit is contained in:
redkale
2023-05-08 19:38:47 +08:00
parent 6ff04b408c
commit 454e6b60d7
2 changed files with 4 additions and 3 deletions

View File

@@ -132,6 +132,7 @@ public class JsonByteBufferReader extends JsonReader {
if (ch == 'N' && nextChar() == 'U' && nextChar() == 'L' && nextChar() == 'L') {
return null;
}
int pos = this.position;
StringBuilder sb = new StringBuilder();
sb.append(ch);
char one;
@@ -139,7 +140,7 @@ public class JsonByteBufferReader extends JsonReader {
while ((one = nextChar()) != 0) sb.append(one);
} catch (Exception e) {
}
throw new ConvertException("a json object text must begin with '{' (position = " + position + ") but '" + ch + "' in (" + sb + ")");
throw new ConvertException("a json object text must begin with '{' (position = " + pos + ") but '" + ch + "' in (" + sb + ")");
}
/**

View File

@@ -365,13 +365,13 @@ public class JsonReader extends Reader {
if (nt == '}' || nt == ']') {
return false;
}
this.position--;
backChar(ch);
return true;
}
if (ch == '}' || ch == ']') {
return false;
}
this.position--; // { [ 交由 readObjectB 或 readMapB 或 readArrayB 读取
backChar(ch); // { [ 交由 readObjectB 或 readMapB 或 readArrayB 读取
return true;
}