bug fixed for jsonparser

This commit is contained in:
wenshao
2013-08-27 19:26:01 +08:00
parent 8b28bd4f57
commit 78f29f09dc
@@ -71,17 +71,17 @@ public class JSONParser {
if (token == Token.LBRACKET) {
return parseArray();
}
if (token == Token.TRUE) {
nextToken();
return true;
}
if (token == Token.FALSE) {
nextToken();
return false;
}
if (token == Token.NULL) {
nextToken();
return null;
@@ -208,7 +208,7 @@ public class JSONParser {
scanDigit();
return;
}
if (text.startsWith("null", index)) {
token = Token.NULL;
index += 3;
@@ -222,7 +222,7 @@ public class JSONParser {
nextChar();
return;
}
if (text.startsWith("false", index)) {
token = Token.FALSE;
index += 4;
@@ -301,6 +301,18 @@ public class JSONParser {
strBuf.append('\f');
} else if (ch == 't') {
strBuf.append('\t');
} else if (ch == 'u') {
nextChar();
char c1 = ch;
nextChar();
char c2 = ch;
nextChar();
char c3 = ch;
nextChar();
char c4 = ch;
int val = Integer.parseInt(new String(new char[] { c1, c2, c3, c4 }), 16);
strBuf.append((char) val);
break;
} else {
throw new IllegalArgumentException("illegal string : " + strBuf);
}