Fixed issue 66 to allow escaped slash ( \/) as a valid Json escaped character.

Changed Gson version to 1.2.3.
This commit is contained in:
Inderjeet Singh 2008-10-29 23:31:13 +00:00
parent 7aa1d0f6aa
commit c98d7bc340
8 changed files with 1498 additions and 1488 deletions

View File

@ -4,7 +4,7 @@
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.2.2</version> <version>1.2.3</version>
<inceptionYear>2008</inceptionYear> <inceptionYear>2008</inceptionYear>
<name>Gson</name> <name>Gson</name>
<url>http://code.google.com/p/google-gson/</url> <url>http://code.google.com/p/google-gson/</url>

View File

@ -1,444 +1,444 @@
/* Generated By:JavaCC: Do not edit this line. JsonParser.java */ /* Generated By:JavaCC: Do not edit this line. JsonParser.java */
package com.google.gson; package com.google.gson;
@SuppressWarnings("all") @SuppressWarnings("all")
final class JsonParser implements JsonParserConstants { final class JsonParser implements JsonParserConstants {
final public JsonElement parse() throws ParseException { final public JsonElement parse() throws ParseException {
JsonElement json = null; JsonElement json = null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 20: case 20:
json = JsonObject(); json = JsonObject();
break; break;
case 25: case 25:
json = JsonArray(); json = JsonArray();
break; break;
case DIGITS: case DIGITS:
case SINGLE_QUOTE_LITERAL: case SINGLE_QUOTE_LITERAL:
case DOUBLE_QUOTE_LITERAL: case DOUBLE_QUOTE_LITERAL:
case 27: case 27:
case 28: case 28:
case 29: case 29:
json = JsonPrimitive(); json = JsonPrimitive();
break; break;
case 22: case 22:
json = JsonNull(); json = JsonNull();
break; break;
default: default:
jj_la1[0] = jj_gen; jj_la1[0] = jj_gen;
jj_consume_token(-1); jj_consume_token(-1);
throw new ParseException(); throw new ParseException();
} }
{if (true) return json;} {if (true) return json;}
throw new Error("Missing return statement in function"); throw new Error("Missing return statement in function");
} }
final private JsonObject JsonObject() throws ParseException { final private JsonObject JsonObject() throws ParseException {
JsonObject o = new JsonObject(); JsonObject o = new JsonObject();
jj_consume_token(20); jj_consume_token(20);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SINGLE_QUOTE_LITERAL: case SINGLE_QUOTE_LITERAL:
case DOUBLE_QUOTE_LITERAL: case DOUBLE_QUOTE_LITERAL:
Members(o); Members(o);
break; break;
default: default:
jj_la1[1] = jj_gen; jj_la1[1] = jj_gen;
; ;
} }
jj_consume_token(21); jj_consume_token(21);
{if (true) return o;} {if (true) return o;}
throw new Error("Missing return statement in function"); throw new Error("Missing return statement in function");
} }
final private JsonNull JsonNull() throws ParseException { final private JsonNull JsonNull() throws ParseException {
JsonNull json = JsonNull.INSTANCE; JsonNull json = JsonNull.INSTANCE;
jj_consume_token(22); jj_consume_token(22);
{if (true) return json;} {if (true) return json;}
throw new Error("Missing return statement in function"); throw new Error("Missing return statement in function");
} }
final private void Members(JsonObject o) throws ParseException { final private void Members(JsonObject o) throws ParseException {
Pair(o); Pair(o);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 23: case 23:
jj_consume_token(23); jj_consume_token(23);
Members(o); Members(o);
break; break;
default: default:
jj_la1[2] = jj_gen; jj_la1[2] = jj_gen;
; ;
} }
} }
final private void Pair(JsonObject o) throws ParseException { final private void Pair(JsonObject o) throws ParseException {
JsonPrimitive property; JsonPrimitive property;
JsonElement value; JsonElement value;
property = JsonString(); property = JsonString();
jj_consume_token(24); jj_consume_token(24);
value = JsonValue(); value = JsonValue();
o.add(property.getAsString(), value); o.add(property.getAsString(), value);
} }
final private JsonArray JsonArray() throws ParseException { final private JsonArray JsonArray() throws ParseException {
JsonArray array = new JsonArray(); JsonArray array = new JsonArray();
jj_consume_token(25); jj_consume_token(25);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case DIGITS: case DIGITS:
case SINGLE_QUOTE_LITERAL: case SINGLE_QUOTE_LITERAL:
case DOUBLE_QUOTE_LITERAL: case DOUBLE_QUOTE_LITERAL:
case 20: case 20:
case 22: case 22:
case 25: case 25:
case 27: case 27:
case 28: case 28:
case 29: case 29:
Elements(array); Elements(array);
break; break;
default: default:
jj_la1[3] = jj_gen; jj_la1[3] = jj_gen;
; ;
} }
jj_consume_token(26); jj_consume_token(26);
array.reverse(); array.reverse();
{if (true) return array;} {if (true) return array;}
throw new Error("Missing return statement in function"); throw new Error("Missing return statement in function");
} }
final private void Elements(JsonArray array) throws ParseException { final private void Elements(JsonArray array) throws ParseException {
JsonElement element; JsonElement element;
element = JsonValue(); element = JsonValue();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 23: case 23:
jj_consume_token(23); jj_consume_token(23);
Elements(array); Elements(array);
break; break;
default: default:
jj_la1[4] = jj_gen; jj_la1[4] = jj_gen;
; ;
} }
array.add(element); array.add(element);
} }
final private JsonElement JsonValue() throws ParseException { final private JsonElement JsonValue() throws ParseException {
JsonElement o = null; JsonElement o = null;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SINGLE_QUOTE_LITERAL: case SINGLE_QUOTE_LITERAL:
case DOUBLE_QUOTE_LITERAL: case DOUBLE_QUOTE_LITERAL:
o = JsonString(); o = JsonString();
break; break;
case DIGITS: case DIGITS:
case 29: case 29:
o = JsonNumber(); o = JsonNumber();
break; break;
case 20: case 20:
o = JsonObject(); o = JsonObject();
break; break;
case 25: case 25:
o = JsonArray(); o = JsonArray();
break; break;
case 27: case 27:
jj_consume_token(27); jj_consume_token(27);
o = new JsonPrimitive(true); o = new JsonPrimitive(true);
break; break;
case 28: case 28:
jj_consume_token(28); jj_consume_token(28);
o = new JsonPrimitive(false); o = new JsonPrimitive(false);
break; break;
case 22: case 22:
jj_consume_token(22); jj_consume_token(22);
break; break;
default: default:
jj_la1[5] = jj_gen; jj_la1[5] = jj_gen;
jj_consume_token(-1); jj_consume_token(-1);
throw new ParseException(); throw new ParseException();
} }
{if (true) return o;} {if (true) return o;}
throw new Error("Missing return statement in function"); throw new Error("Missing return statement in function");
} }
final private JsonPrimitive JsonPrimitive() throws ParseException { final private JsonPrimitive JsonPrimitive() throws ParseException {
JsonPrimitive value; JsonPrimitive value;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SINGLE_QUOTE_LITERAL: case SINGLE_QUOTE_LITERAL:
case DOUBLE_QUOTE_LITERAL: case DOUBLE_QUOTE_LITERAL:
value = JsonString(); value = JsonString();
{if (true) return value;} {if (true) return value;}
break; break;
case DIGITS: case DIGITS:
case 29: case 29:
value = JsonNumber(); value = JsonNumber();
{if (true) return value;} {if (true) return value;}
break; break;
case 27: case 27:
jj_consume_token(27); jj_consume_token(27);
{if (true) return new JsonPrimitive(true);} {if (true) return new JsonPrimitive(true);}
break; break;
case 28: case 28:
jj_consume_token(28); jj_consume_token(28);
{if (true) return new JsonPrimitive(false);} {if (true) return new JsonPrimitive(false);}
break; break;
default: default:
jj_la1[6] = jj_gen; jj_la1[6] = jj_gen;
jj_consume_token(-1); jj_consume_token(-1);
throw new ParseException(); throw new ParseException();
} }
throw new Error("Missing return statement in function"); throw new Error("Missing return statement in function");
} }
final private JsonPrimitive JsonNumber() throws ParseException { final private JsonPrimitive JsonNumber() throws ParseException {
String intpart = null, String intpart = null,
fracpart = null, fracpart = null,
exppart = null; exppart = null;
intpart = JsonInt(); intpart = JsonInt();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 30: case 30:
fracpart = JsonFrac(); fracpart = JsonFrac();
break; break;
default: default:
jj_la1[7] = jj_gen; jj_la1[7] = jj_gen;
; ;
} }
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case E: case E:
exppart = JsonExp(); exppart = JsonExp();
break; break;
default: default:
jj_la1[8] = jj_gen; jj_la1[8] = jj_gen;
; ;
} }
Number n; Number n;
if (exppart != null) { if (exppart != null) {
n = new java.math.BigDecimal(intpart + fracpart + exppart); n = new java.math.BigDecimal(intpart + fracpart + exppart);
} else if (fracpart != null) { } else if (fracpart != null) {
n = new Double(intpart + fracpart); n = new Double(intpart + fracpart);
} else { } else {
// See if the number fits in an integer, or long // See if the number fits in an integer, or long
// Use BigInteger only if it is big enough. // Use BigInteger only if it is big enough.
if (intpart.length() < 10) { if (intpart.length() < 10) {
n = new Integer(intpart); n = new Integer(intpart);
} else if (intpart.length() < 19) { } else if (intpart.length() < 19) {
n = new Long(intpart); n = new Long(intpart);
} else { } else {
n = new java.math.BigInteger(intpart); n = new java.math.BigInteger(intpart);
} }
} }
{if (true) return new JsonPrimitive(n);} {if (true) return new JsonPrimitive(n);}
throw new Error("Missing return statement in function"); throw new Error("Missing return statement in function");
} }
final private String JsonInt() throws ParseException { final private String JsonInt() throws ParseException {
String digits; String digits;
boolean negative = false; boolean negative = false;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 29: case 29:
jj_consume_token(29); jj_consume_token(29);
negative = true; negative = true;
break; break;
default: default:
jj_la1[9] = jj_gen; jj_la1[9] = jj_gen;
; ;
} }
digits = Digits(); digits = Digits();
if(negative) if(negative)
{if (true) return "-" + digits;} {if (true) return "-" + digits;}
{if (true) return digits;} {if (true) return digits;}
throw new Error("Missing return statement in function"); throw new Error("Missing return statement in function");
} }
final private String JsonFrac() throws ParseException { final private String JsonFrac() throws ParseException {
String digits; String digits;
jj_consume_token(30); jj_consume_token(30);
digits = Digits(); digits = Digits();
{if (true) return "." + digits;} {if (true) return "." + digits;}
throw new Error("Missing return statement in function"); throw new Error("Missing return statement in function");
} }
final private String JsonExp() throws ParseException { final private String JsonExp() throws ParseException {
Token t; Token t;
String digits; String digits;
t = jj_consume_token(E); t = jj_consume_token(E);
digits = Digits(); digits = Digits();
{if (true) return t.image + digits;} {if (true) return t.image + digits;}
throw new Error("Missing return statement in function"); throw new Error("Missing return statement in function");
} }
final private String Digits() throws ParseException { final private String Digits() throws ParseException {
Token t; Token t;
t = jj_consume_token(DIGITS); t = jj_consume_token(DIGITS);
{if (true) return t.image;} {if (true) return t.image;}
throw new Error("Missing return statement in function"); throw new Error("Missing return statement in function");
} }
final private JsonPrimitive JsonString() throws ParseException { final private JsonPrimitive JsonString() throws ParseException {
Token t; Token t;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SINGLE_QUOTE_LITERAL: case SINGLE_QUOTE_LITERAL:
t = jj_consume_token(SINGLE_QUOTE_LITERAL); t = jj_consume_token(SINGLE_QUOTE_LITERAL);
break; break;
case DOUBLE_QUOTE_LITERAL: case DOUBLE_QUOTE_LITERAL:
t = jj_consume_token(DOUBLE_QUOTE_LITERAL); t = jj_consume_token(DOUBLE_QUOTE_LITERAL);
break; break;
default: default:
jj_la1[10] = jj_gen; jj_la1[10] = jj_gen;
jj_consume_token(-1); jj_consume_token(-1);
throw new ParseException(); throw new ParseException();
} }
String value = StringUnmarshaller.unmarshall(t.image); String value = StringUnmarshaller.unmarshall(t.image);
{if (true) return new JsonPrimitive(value);} {if (true) return new JsonPrimitive(value);}
throw new Error("Missing return statement in function"); throw new Error("Missing return statement in function");
} }
public JsonParserTokenManager token_source; public JsonParserTokenManager token_source;
SimpleCharStream jj_input_stream; SimpleCharStream jj_input_stream;
public Token token, jj_nt; public Token token, jj_nt;
private int jj_ntk; private int jj_ntk;
private int jj_gen; private int jj_gen;
final private int[] jj_la1 = new int[11]; final private int[] jj_la1 = new int[11];
static private int[] jj_la1_0; static private int[] jj_la1_0;
static { static {
jj_la1_0(); jj_la1_0();
} }
private static void jj_la1_0() { private static void jj_la1_0() {
jj_la1_0 = new int[] {0x3a500c40,0xc00,0x800000,0x3a500c40,0x800000,0x3a500c40,0x38000c40,0x40000000,0x20,0x20000000,0xc00,}; jj_la1_0 = new int[] {0x3a500c40,0xc00,0x800000,0x3a500c40,0x800000,0x3a500c40,0x38000c40,0x40000000,0x20,0x20000000,0xc00,};
} }
public JsonParser(java.io.InputStream stream) { public JsonParser(java.io.InputStream stream) {
this(stream, null); this(stream, null);
} }
public JsonParser(java.io.InputStream stream, String encoding) { public JsonParser(java.io.InputStream stream, String encoding) {
try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
token_source = new JsonParserTokenManager(jj_input_stream); token_source = new JsonParserTokenManager(jj_input_stream);
token = new Token(); token = new Token();
jj_ntk = -1; jj_ntk = -1;
jj_gen = 0; jj_gen = 0;
for (int i = 0; i < 11; i++) jj_la1[i] = -1; for (int i = 0; i < 11; i++) jj_la1[i] = -1;
} }
public void ReInit(java.io.InputStream stream) { public void ReInit(java.io.InputStream stream) {
ReInit(stream, null); ReInit(stream, null);
} }
public void ReInit(java.io.InputStream stream, String encoding) { public void ReInit(java.io.InputStream stream, String encoding) {
try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
token_source.ReInit(jj_input_stream); token_source.ReInit(jj_input_stream);
token = new Token(); token = new Token();
jj_ntk = -1; jj_ntk = -1;
jj_gen = 0; jj_gen = 0;
for (int i = 0; i < 11; i++) jj_la1[i] = -1; for (int i = 0; i < 11; i++) jj_la1[i] = -1;
} }
public JsonParser(java.io.Reader stream) { public JsonParser(java.io.Reader stream) {
jj_input_stream = new SimpleCharStream(stream, 1, 1); jj_input_stream = new SimpleCharStream(stream, 1, 1);
token_source = new JsonParserTokenManager(jj_input_stream); token_source = new JsonParserTokenManager(jj_input_stream);
token = new Token(); token = new Token();
jj_ntk = -1; jj_ntk = -1;
jj_gen = 0; jj_gen = 0;
for (int i = 0; i < 11; i++) jj_la1[i] = -1; for (int i = 0; i < 11; i++) jj_la1[i] = -1;
} }
public void ReInit(java.io.Reader stream) { public void ReInit(java.io.Reader stream) {
jj_input_stream.ReInit(stream, 1, 1); jj_input_stream.ReInit(stream, 1, 1);
token_source.ReInit(jj_input_stream); token_source.ReInit(jj_input_stream);
token = new Token(); token = new Token();
jj_ntk = -1; jj_ntk = -1;
jj_gen = 0; jj_gen = 0;
for (int i = 0; i < 11; i++) jj_la1[i] = -1; for (int i = 0; i < 11; i++) jj_la1[i] = -1;
} }
public JsonParser(JsonParserTokenManager tm) { public JsonParser(JsonParserTokenManager tm) {
token_source = tm; token_source = tm;
token = new Token(); token = new Token();
jj_ntk = -1; jj_ntk = -1;
jj_gen = 0; jj_gen = 0;
for (int i = 0; i < 11; i++) jj_la1[i] = -1; for (int i = 0; i < 11; i++) jj_la1[i] = -1;
} }
public void ReInit(JsonParserTokenManager tm) { public void ReInit(JsonParserTokenManager tm) {
token_source = tm; token_source = tm;
token = new Token(); token = new Token();
jj_ntk = -1; jj_ntk = -1;
jj_gen = 0; jj_gen = 0;
for (int i = 0; i < 11; i++) jj_la1[i] = -1; for (int i = 0; i < 11; i++) jj_la1[i] = -1;
} }
final private Token jj_consume_token(int kind) throws ParseException { final private Token jj_consume_token(int kind) throws ParseException {
Token oldToken; Token oldToken;
if ((oldToken = token).next != null) token = token.next; if ((oldToken = token).next != null) token = token.next;
else token = token.next = token_source.getNextToken(); else token = token.next = token_source.getNextToken();
jj_ntk = -1; jj_ntk = -1;
if (token.kind == kind) { if (token.kind == kind) {
jj_gen++; jj_gen++;
return token; return token;
} }
token = oldToken; token = oldToken;
jj_kind = kind; jj_kind = kind;
throw generateParseException(); throw generateParseException();
} }
final public Token getNextToken() { final public Token getNextToken() {
if (token.next != null) token = token.next; if (token.next != null) token = token.next;
else token = token.next = token_source.getNextToken(); else token = token.next = token_source.getNextToken();
jj_ntk = -1; jj_ntk = -1;
jj_gen++; jj_gen++;
return token; return token;
} }
final public Token getToken(int index) { final public Token getToken(int index) {
Token t = token; Token t = token;
for (int i = 0; i < index; i++) { for (int i = 0; i < index; i++) {
if (t.next != null) t = t.next; if (t.next != null) t = t.next;
else t = t.next = token_source.getNextToken(); else t = t.next = token_source.getNextToken();
} }
return t; return t;
} }
final private int jj_ntk() { final private int jj_ntk() {
if ((jj_nt=token.next) == null) if ((jj_nt=token.next) == null)
return (jj_ntk = (token.next=token_source.getNextToken()).kind); return (jj_ntk = (token.next=token_source.getNextToken()).kind);
else else
return (jj_ntk = jj_nt.kind); return (jj_ntk = jj_nt.kind);
} }
private java.util.Vector jj_expentries = new java.util.Vector(); private java.util.Vector jj_expentries = new java.util.Vector();
private int[] jj_expentry; private int[] jj_expentry;
private int jj_kind = -1; private int jj_kind = -1;
public ParseException generateParseException() { public ParseException generateParseException() {
jj_expentries.removeAllElements(); jj_expentries.removeAllElements();
boolean[] la1tokens = new boolean[31]; boolean[] la1tokens = new boolean[31];
for (int i = 0; i < 31; i++) { for (int i = 0; i < 31; i++) {
la1tokens[i] = false; la1tokens[i] = false;
} }
if (jj_kind >= 0) { if (jj_kind >= 0) {
la1tokens[jj_kind] = true; la1tokens[jj_kind] = true;
jj_kind = -1; jj_kind = -1;
} }
for (int i = 0; i < 11; i++) { for (int i = 0; i < 11; i++) {
if (jj_la1[i] == jj_gen) { if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) { for (int j = 0; j < 32; j++) {
if ((jj_la1_0[i] & (1<<j)) != 0) { if ((jj_la1_0[i] & (1<<j)) != 0) {
la1tokens[j] = true; la1tokens[j] = true;
} }
} }
} }
} }
for (int i = 0; i < 31; i++) { for (int i = 0; i < 31; i++) {
if (la1tokens[i]) { if (la1tokens[i]) {
jj_expentry = new int[1]; jj_expentry = new int[1];
jj_expentry[0] = i; jj_expentry[0] = i;
jj_expentries.addElement(jj_expentry); jj_expentries.addElement(jj_expentry);
} }
} }
int[][] exptokseq = new int[jj_expentries.size()][]; int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) { for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = (int[])jj_expentries.elementAt(i); exptokseq[i] = (int[])jj_expentries.elementAt(i);
} }
return new ParseException(token, exptokseq, tokenImage); return new ParseException(token, exptokseq, tokenImage);
} }
final public void enable_tracing() { final public void enable_tracing() {
} }
final public void disable_tracing() { final public void disable_tracing() {
} }
} }

View File

@ -1,60 +1,60 @@
/* Generated By:JavaCC: Do not edit this line. JsonParserConstants.java */ /* Generated By:JavaCC: Do not edit this line. JsonParserConstants.java */
package com.google.gson; package com.google.gson;
interface JsonParserConstants { interface JsonParserConstants {
int EOF = 0; int EOF = 0;
int E = 5; int E = 5;
int DIGITS = 6; int DIGITS = 6;
int HEX_CHAR = 7; int HEX_CHAR = 7;
int UNICODE_CHAR = 8; int UNICODE_CHAR = 8;
int ESCAPE_CHAR = 9; int ESCAPE_CHAR = 9;
int SINGLE_QUOTE_LITERAL = 10; int SINGLE_QUOTE_LITERAL = 10;
int DOUBLE_QUOTE_LITERAL = 11; int DOUBLE_QUOTE_LITERAL = 11;
int QUOTE = 12; int QUOTE = 12;
int ENDQUOTE = 14; int ENDQUOTE = 14;
int CHAR = 15; int CHAR = 15;
int CNTRL_ESC = 16; int CNTRL_ESC = 16;
int HEX = 18; int HEX = 18;
int HEX_ESC = 19; int HEX_ESC = 19;
int DEFAULT = 0; int DEFAULT = 0;
int STRING_STATE = 1; int STRING_STATE = 1;
int ESC_STATE = 2; int ESC_STATE = 2;
int HEX_STATE = 3; int HEX_STATE = 3;
String[] tokenImage = { String[] tokenImage = {
"<EOF>", "<EOF>",
"\" \"", "\" \"",
"\"\\t\"", "\"\\t\"",
"\"\\n\"", "\"\\n\"",
"\"\\r\"", "\"\\r\"",
"<E>", "<E>",
"<DIGITS>", "<DIGITS>",
"<HEX_CHAR>", "<HEX_CHAR>",
"<UNICODE_CHAR>", "<UNICODE_CHAR>",
"<ESCAPE_CHAR>", "<ESCAPE_CHAR>",
"<SINGLE_QUOTE_LITERAL>", "<SINGLE_QUOTE_LITERAL>",
"<DOUBLE_QUOTE_LITERAL>", "<DOUBLE_QUOTE_LITERAL>",
"\"\\\"\"", "\"\\\"\"",
"\"\\\\\"", "\"\\\\\"",
"<ENDQUOTE>", "<ENDQUOTE>",
"<CHAR>", "<CHAR>",
"<CNTRL_ESC>", "<CNTRL_ESC>",
"\"u\"", "\"u\"",
"<HEX>", "<HEX>",
"<HEX_ESC>", "<HEX_ESC>",
"\"{\"", "\"{\"",
"\"}\"", "\"}\"",
"\"null\"", "\"null\"",
"\",\"", "\",\"",
"\":\"", "\":\"",
"\"[\"", "\"[\"",
"\"]\"", "\"]\"",
"\"true\"", "\"true\"",
"\"false\"", "\"false\"",
"\"-\"", "\"-\"",
"\".\"", "\".\"",
}; };
} }

File diff suppressed because it is too large Load Diff

View File

@ -63,6 +63,9 @@ final class StringUnmarshaller {
case '\\': case '\\':
ch = '\\'; ch = '\\';
break; break;
case '/':
ch = '/';
break;
default: default:
throw new IllegalStateException("Unexpected character: " + c + " in " + str); throw new IllegalStateException("Unexpected character: " + c + " in " + str);
} }

View File

@ -30,7 +30,7 @@ TOKEN : {
| <DIGITS : (["0"-"9"])+> | <DIGITS : (["0"-"9"])+>
| <#HEX_CHAR : ["a"-"f","A"-"F","0"-"9"]> | <#HEX_CHAR : ["a"-"f","A"-"F","0"-"9"]>
| <UNICODE_CHAR : "\\u" <HEX_CHAR><HEX_CHAR><HEX_CHAR><HEX_CHAR> > | <UNICODE_CHAR : "\\u" <HEX_CHAR><HEX_CHAR><HEX_CHAR><HEX_CHAR> >
| <#ESCAPE_CHAR: "\\" ["n","t","b","r","f","\\","'","\""] > | <#ESCAPE_CHAR: "\\" ["n","t","b","r","f","\\","'","\"", "/"] >
| <SINGLE_QUOTE_LITERAL: "\'" ( (~["\'","\\","\n","\r"]) | <ESCAPE_CHAR> | <UNICODE_CHAR>)* "\'" > | <SINGLE_QUOTE_LITERAL: "\'" ( (~["\'","\\","\n","\r"]) | <ESCAPE_CHAR> | <UNICODE_CHAR>)* "\'" >
| <DOUBLE_QUOTE_LITERAL: "\"" ( (~["\"","\\","\n","\r"]) | <ESCAPE_CHAR> | <UNICODE_CHAR>)* "\"" > | <DOUBLE_QUOTE_LITERAL: "\"" ( (~["\"","\\","\n","\r"]) | <ESCAPE_CHAR> | <UNICODE_CHAR>)* "\"" >
| <QUOTE : "\""> : STRING_STATE | <QUOTE : "\""> : STRING_STATE

View File

@ -122,9 +122,9 @@ public class ConcurrencyTest extends TestCase {
} }
private static class MyObject { private static class MyObject {
private String a; String a;
private String b; String b;
private int i; int i;
MyObject() { MyObject() {
this("hello", "world", 42); this("hello", "world", 42);

View File

@ -102,4 +102,11 @@ public class StringTest extends TestCase {
String actual = gson.fromJson("[\"" + value + "\"]", String.class); String actual = gson.fromJson("[\"" + value + "\"]", String.class);
assertEquals(value, actual); assertEquals(value, actual);
} }
public void testStringWithEscapedSlashDeserialization() {
String value = "/";
String json = "'\\/'";
String actual = gson.fromJson(json, String.class);
assertEquals(value, actual);
}
} }