json
This commit is contained in:
@@ -180,13 +180,13 @@ public class JsonReader extends Reader {
|
|||||||
* @return 有效字符
|
* @return 有效字符
|
||||||
*/
|
*/
|
||||||
protected char nextGoodChar(boolean allowComment) {
|
protected char nextGoodChar(boolean allowComment) {
|
||||||
char[] text0 = this.text;
|
char c = this.text[++this.position];
|
||||||
int end = this.limit;
|
|
||||||
int curr = ++this.position;
|
|
||||||
char c = text0[curr];
|
|
||||||
if (c > ' ' && c != '/') {
|
if (c > ' ' && c != '/') {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
char[] text0 = this.text;
|
||||||
|
int end = this.limit;
|
||||||
|
int curr = this.position;
|
||||||
for (; curr <= end; curr++) {
|
for (; curr <= end; curr++) {
|
||||||
c = text0[curr];
|
c = text0[curr];
|
||||||
if (c > ' ') {
|
if (c > ' ') {
|
||||||
@@ -419,52 +419,28 @@ public class JsonReader extends Reader {
|
|||||||
if (negative) {
|
if (negative) {
|
||||||
throw new ConvertException("illegal escape(" + firstchar + ") (position = " + position + ")");
|
throw new ConvertException("illegal escape(" + firstchar + ") (position = " + position + ")");
|
||||||
}
|
}
|
||||||
char c = nextChar();
|
if (nextChar() != 'a' || nextChar() != 'N') {
|
||||||
if (c != 'a') {
|
throw new ConvertException("illegal escape(" + text[position] + ") (position = " + position + ")");
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|
||||||
}
|
|
||||||
c = nextChar();
|
|
||||||
if (c != 'N') {
|
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|
||||||
}
|
}
|
||||||
if (quote) {
|
if (quote) {
|
||||||
c = nextChar();
|
char c = nextChar();
|
||||||
if (c != '"' && c != '\'') {
|
if (c != '"' && c != '\'') {
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0; // NaN 返回0;
|
return 0; // NaN 返回0;
|
||||||
} else if (firstchar == 'I') { // Infinity
|
} else if (firstchar == 'I') { // Infinity
|
||||||
char c = nextChar();
|
if (nextChar() != 'n'
|
||||||
if (c != 'n') {
|
|| nextChar() != 'f'
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|| nextChar() != 'i'
|
||||||
}
|
|| nextChar() != 'n'
|
||||||
c = nextChar();
|
|| nextChar() != 'i'
|
||||||
if (c != 'f') {
|
|| nextChar() != 't'
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|| nextChar() != 'y') {
|
||||||
}
|
throw new ConvertException("illegal escape(" + text[position] + ") (position = " + position + ")");
|
||||||
c = nextChar();
|
|
||||||
if (c != 'i') {
|
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|
||||||
}
|
|
||||||
c = nextChar();
|
|
||||||
if (c != 'n') {
|
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|
||||||
}
|
|
||||||
c = nextChar();
|
|
||||||
if (c != 'i') {
|
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|
||||||
}
|
|
||||||
c = nextChar();
|
|
||||||
if (c != 't') {
|
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|
||||||
}
|
|
||||||
c = nextChar();
|
|
||||||
if (c != 'y') {
|
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|
||||||
}
|
}
|
||||||
if (quote) {
|
if (quote) {
|
||||||
c = nextChar();
|
char c = nextChar();
|
||||||
if (c != '"' && c != '\'') {
|
if (c != '"' && c != '\'') {
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
||||||
}
|
}
|
||||||
@@ -582,52 +558,28 @@ public class JsonReader extends Reader {
|
|||||||
if (negative) {
|
if (negative) {
|
||||||
throw new ConvertException("illegal escape(" + firstchar + ") (position = " + position + ")");
|
throw new ConvertException("illegal escape(" + firstchar + ") (position = " + position + ")");
|
||||||
}
|
}
|
||||||
char c = nextChar();
|
if (nextChar() != 'a' || nextChar() != 'N') {
|
||||||
if (c != 'a') {
|
throw new ConvertException("illegal escape(" + text[position] + ") (position = " + position + ")");
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|
||||||
}
|
|
||||||
c = nextChar();
|
|
||||||
if (c != 'N') {
|
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|
||||||
}
|
}
|
||||||
if (quote) {
|
if (quote) {
|
||||||
c = nextChar();
|
char c = nextChar();
|
||||||
if (c != '"' && c != '\'') {
|
if (c != '"' && c != '\'') {
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0L; // NaN 返回0;
|
return 0L; // NaN 返回0;
|
||||||
} else if (firstchar == 'I') { // Infinity
|
} else if (firstchar == 'I') { // Infinity
|
||||||
char c = nextChar();
|
if (nextChar() != 'n'
|
||||||
if (c != 'n') {
|
|| nextChar() != 'f'
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|| nextChar() != 'i'
|
||||||
}
|
|| nextChar() != 'n'
|
||||||
c = nextChar();
|
|| nextChar() != 'i'
|
||||||
if (c != 'f') {
|
|| nextChar() != 't'
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|| nextChar() != 'y') {
|
||||||
}
|
throw new ConvertException("illegal escape(" + text[position] + ") (position = " + position + ")");
|
||||||
c = nextChar();
|
|
||||||
if (c != 'i') {
|
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|
||||||
}
|
|
||||||
c = nextChar();
|
|
||||||
if (c != 'n') {
|
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|
||||||
}
|
|
||||||
c = nextChar();
|
|
||||||
if (c != 'i') {
|
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|
||||||
}
|
|
||||||
c = nextChar();
|
|
||||||
if (c != 't') {
|
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|
||||||
}
|
|
||||||
c = nextChar();
|
|
||||||
if (c != 'y') {
|
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
|
||||||
}
|
}
|
||||||
if (quote) {
|
if (quote) {
|
||||||
c = nextChar();
|
char c = nextChar();
|
||||||
if (c != '"' && c != '\'') {
|
if (c != '"' && c != '\'') {
|
||||||
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
throw new ConvertException("illegal escape(" + c + ") (position = " + position + ")");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user