Test demonstrating a bug reported in issue 178, wherein malformed JSON is emitted when a map key contains a double-quote.

This commit is contained in:
Jesse Wilson 2010-08-20 05:43:17 +00:00
parent cb6de44b56
commit 8b5cc3256d

View File

@ -287,4 +287,14 @@ public class MapTest extends TestCase {
assertEquals("1", nested.get("1"));
assertEquals("2", nested.get("2"));
}
/**
* From bug report http://code.google.com/p/google-gson/issues/detail?id=178
*/
public void testMapWithQuotes() {
Map<String, String> map = new HashMap<String, String>();
map.put("a\"b", "c\"d");
String json = gson.toJson(map);
assertEquals("{\"a\\\"b\":\"c\\\"d\"}", json);
}
}