TypeAdapter for String.Class doesn't work on gson 2.1 (was working on previous
version)
here a small test case:
expected output should be "test", but i got "candy" instead.
Note: this issue is only relative to the current 'stable' release.
------
public class TestCase {
public static void main(String[] args) {
String test = "candy";
Gson gson = new GsonBuilder()
.excludeFieldsWithModifiers(java.lang.reflect.Modifier.TRANSIENT)
.registerTypeAdapter(String.class, new JsonSerializer<String>() {
public JsonElement serialize(String src, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive("test");
}
}).setPrettyPrinting().create();
System.out.println(gson.toJson(test, String.class));
}
}
Original issue reported on code.google.com by ramarr...@gmail.com on 1 Feb 2012 at 9:01
Original issue reported on code.google.com by
ramarr...@gmail.com
on 1 Feb 2012 at 9:01