Some webservices provide JSON with ascii hex excape sequences in them.
json-smart should support this...
What steps will reproduce the problem?
1. Attempt to parse some JSON which contains an ASCII hex excape sequence like
\x27
2.
3.
What is the expected output? What do you see instead?
\x27 should be parsed as '
What version of the product are you using? On what operating system?
V1.1.1
Please provide any additional information below.
I made the following changes to support ascii hex excape sequences...
In JSONParserBase:
In readString2()
case 'u':
sb.append(readUnicode());
case 'x'://<--- Added line
sb.append(readAsciHexExcapeCode());//<--- Added line
protected char readAsciHexExcapeCode() throws IOException, ParseException
{
return readUnicode(2);
}
protected char readUnicode() throws ParseException, IOException {
return readUnicode(4);
}
protected char readUnicode(int totalChars) throws IOException, ParseException
{
int value = 0;
for (int i = 0; i < totalChars; i++) {
value = value * 16;
read();
if (c <= '9' && c >= '0')
value += c - '0';
else if (c <= 'F' && c >= 'A')
value += (c - 'A') + 10;
else if (c >= 'a' && c <= 'f')
value += (c - 'a') + 10;
else if (c == EOI)
throw new ParseException(pos, ERROR_UNEXPECTED_EOF, "EOF");
else
throw new ParseException(pos, ERROR_UNEXPECTED_UNICODE, c);
}
return (char) value;
}
Original issue reported on code.google.com by calsc...@gmail.com on 8 May 2013 at 6:14
Original issue reported on code.google.com by
calsc...@gmail.com
on 8 May 2013 at 6:14