Closed GoogleCodeExporter closed 9 years ago
You should be able to accomplish this without modifying any of the Gson code,
but
rather creating your own serializers for longs, float, double, etc.
Here is an example of a Long serializer:
public class MyLongSerializer implements JsonSerializer<Long> {
public JsonElement serialize(Long src, Type typeOfSrc, JsonSerializationContext
context) {
return new JsonPrimitive(String.valueOf(src));
}
}
You would then register these custom serializers using the GsonBuilder.
Hope this helps,
Joel
Original comment by joel.leitch@gmail.com
on 18 Aug 2009 at 6:01
Having Gson output a number as a number and not as a string is a feature not a
bug.
Original comment by inder123
on 23 Sep 2009 at 7:05
Original issue reported on code.google.com by
pudur.ra...@gmail.com
on 30 Jul 2009 at 9:31