Open GoogleCodeExporter opened 9 years ago
This support will also fix the problem where you want to mark certain fields as
required.
Original comment by inder123
on 26 Nov 2010 at 7:10
Original comment by limpbizkit
on 12 Feb 2012 at 8:44
What's the status of this issue? If fixed, can you explain me how to do it in
version 2.2.4?
Original comment by laurent.verbruggen@gmail.com
on 7 Jun 2013 at 1:27
No current plans to implement this though it is something I want to happen.
If you have a specific proposal, it would be great.
Original comment by inder123
on 7 Jun 2013 at 6:20
This would be really useful.
Original comment by wagnerfr...@gmail.com
on 18 Jul 2013 at 12:24
One simple example: I'm using Objectify on AppEngine, and so one of my entity
classes is like so:
public class MyThing {
@Id Long id;
String title;
}
I want this to map to:
{"id":443,"title":"Thing"}
If I could write a type adapter that triggers off annotations, I could just use
the existing @Id annnotation to ensure the Long is serialized as a String
Original comment by steve.ar...@gmail.com
on 7 Aug 2014 at 5:40
I needed this kind of functionality too so I started to modify gson code as a
proof of concept. Basically, I created a new adapter factory interface
(AnnotatedTypeAdapterFactory) that takes an extra argument (TypeAttributes,
which is an abstraction of FieldAttributes similar to AnnotatedElement in Java)
<T> TypeAdapter<T> create(Gson gson, TypeAttributes attributes, TypeToken<T> type);
This way, it is possible to create a custom factory that does what it needs to
do (and possibly, there could be annotations supported directly by Gson).
The attached diff file can be applied to the trunk svn version from within the
gson directory.
Original comment by benja...@bpiwowar.net
on 4 Oct 2014 at 10:46
Attachments:
Original issue reported on code.google.com by
inder123
on 26 Nov 2010 at 7:00