Hey everyone -
I have some legacy objects in my code base that I wanted to convert to and
from json with the BeanJsonConverter and JsonProperty. Problem is, it seems
that the same logic/annotation is being used to find getters and setters on
my pojos. So when I try to convert my pojo to a string, it ends up trying to
call setters, and not getters (or vice versa).
For example, I have a class Post.java with two fields "title" and "body".
Add setters and getters for these fields and things work dandy. However, I
need my json to use capital case: "Title" and "Body". To do this I figure I
need JsonProperty. So I go and add the JsonProperty("Title") and the other
annotation to the setters and who hoo I can take my json into a pojo with
capital case. But then - on the way from pojo to json the code grabs all
methods, and if they have a jsonProperty - it puts them in the getter map!
Unfortunately, this causes an IllegalArgException because of course my
setters take params, and the code is expecting them to be getters...
So, I'm thinking we either need a JsonGetProperty and JsonSetProperty
annotation. Or, the code needs to check that a property exists -and- that
the method starts with "get" or "set" or maybe there is something better...
Anyway, did I completely screw something up here? Is someone getting this to
work correctly?
If not, how should we fix it?
Thanks!
- Cassie