class Demo {
private String name;
private int total;
...
}
When I'm serializing an object of demo with gson, I'll get something like this in the normal scenario:
{"name": "hello world", "total": 100}
Now, I have an annotation @Xyz which can be added to any attribute of any class. (The attribute to which I can apply this annotation can be anything, but for now it should be okay if it is just String type )
class Demo {
@Xyz
private String name;
private int total;
...
}
When I've the annotation on the class attribute, the serialized data should be of the following format:
{"name": {"value": "hello world", "xyzEnabled": true}, "total": 100}
Please note that this annotation can be applied to any (String) field regardless of the type of the class. If I could somehow get the declared annotations for that specific field on the custom serialiser serialize method, that would work for me.
Please advice how to achieve this.