Issue 269 in google-gson: Add support for custom actions on annotations

0 views
Skip to first unread message

googl...@googlecode.com

unread,
Nov 26, 2010, 2:00:14 PM11/26/10
to google-gson...@googlegroups.com
Status: Accepted
Owner: inder123
Labels: Type-Enhancement Priority-Medium Milestone-Release1.7

New issue 269 by inder123: Add support for custom actions on annotations
http://code.google.com/p/google-gson/issues/detail?id=269

See the thread:
http://groups.google.com/group/google-gson/browse_thread/thread/1ea949a5e50cc507

by supporting a custom action on an annotation, we will enable support for
JPA/Hibernate and other kinds of annotations.

googl...@googlecode.com

unread,
Nov 26, 2010, 2:10:22 PM11/26/10
to google-gson...@googlegroups.com

Comment #1 on issue 269 by inder123: Add support for custom actions on
annotations
http://code.google.com/p/google-gson/issues/detail?id=269

This support will also fix the problem where you want to mark certain
fields as required.

googl...@googlecode.com

unread,
Feb 12, 2012, 3:58:56 PM2/12/12
to google-gson...@googlegroups.com
Updates:
Labels: -Milestone-Release1.7

Comment #2 on issue 269 by limpbiz...@gmail.com: Add support for custom

(No comment was entered for this change.)

googl...@googlecode.com

unread,
Jun 7, 2013, 9:27:24 AM6/7/13
to google-gson...@googlegroups.com

Comment #3 on issue 269 by laurent.v...@gmail.com: Add support for
What's the status of this issue? If fixed, can you explain me how to do it
in version 2.2.4?

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

googl...@googlecode.com

unread,
Jun 7, 2013, 2:20:36 PM6/7/13
to google-gson...@googlegroups.com

Comment #4 on issue 269 by inder123: Add support for custom actions on
annotations
http://code.google.com/p/google-gson/issues/detail?id=269

No current plans to implement this though it is something I want to happen.
If you have a specific proposal, it would be great.

googl...@googlecode.com

unread,
Jul 18, 2013, 8:24:50 AM7/18/13
to google-gson...@googlegroups.com

Comment #5 on issue 269 by wagnerfr...@gmail.com: Add support for custom
This would be really useful.

googl...@googlecode.com

unread,
Aug 7, 2014, 1:40:21 AM8/7/14
to google-gson...@googlegroups.com

Comment #6 on issue 269 by steve.ar...@gmail.com: Add support for custom
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

googl...@googlecode.com

unread,
Oct 4, 2014, 6:46:55 AM10/4/14
to google-gson...@googlegroups.com

Comment #7 on issue 269 by benja...@bpiwowar.net: Add support for custom
actions on annotations
https://code.google.com/p/google-gson/issues/detail?id=269

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.

Attachments:
gson-types.diff 59.1 KB

googl...@googlecode.com

unread,
Jun 9, 2015, 12:14:23 PM6/9/15
to google-gson...@googlegroups.com

Comment #8 on issue 269 by markspen...@gmail.com: Add support for custom
Any update on this? I would like to use this for my own custom annotations
on fields.

googl...@googlecode.com

unread,
Jun 9, 2015, 12:15:23 PM6/9/15
to google-gson...@googlegroups.com

Comment #9 on issue 269 by m...@doolli.com: Add support for custom actions
on annotations
https://code.google.com/p/google-gson/issues/detail?id=269

Any updates or plans for this? I would like to be able to use my own custom
annotations when serializing certain fields.

googl...@googlecode.com

unread,
Jun 9, 2015, 12:17:05 PM6/9/15
to google-gson...@googlegroups.com

Comment #10 on issue 269 by benjamin...@gmail.com: Add support for custom
Hi,

I released a modified version of gson if you need this:

<dependencies>
<dependency>
<groupId>net.bpiwowar</groupId>
<artifactId>fson</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>

googl...@googlecode.com

unread,
Jun 17, 2015, 12:59:53 PM6/17/15
to google-gson...@googlegroups.com

Comment #11 on issue 269 by mrz...@gmail.com: Add support for custom
is the 2.3.1 version of fson mean that its a fork of gson 2.3.1?

googl...@googlecode.com

unread,
Jun 17, 2015, 1:05:41 PM6/17/15
to google-gson...@googlegroups.com

Comment #12 on issue 269 by benjamin...@gmail.com: Add support for custom
Yes - I will try to keep a correspondance with fson 2.3.1-1, etc. versions
in case there is another gson version and the patch is not included
Reply all
Reply to author
Forward
0 new messages