Parse response to a POJO without annotations?

37 views
Skip to first unread message

Jason Frank

unread,
Feb 14, 2014, 5:35:04 PM2/14/14
to google-http...@googlegroups.com
The service that I'm interacting with has a library that defines the response POJO, let's call that class ServiceResponse.  I tried just a simple "response.parseAs(ServiceResponse.class)" but to my surprise no fields got populated.  (I've used Jackson before to do this kind of thing, and it just fills in the object so that's what I was expecting).  From reading the developer guide, it indicates that the JSON serialize / deserialize will only pay attention to fields annotated with @Key.  What is the recommended coding pattern in this case, when I can't add annotations to a library class?  Is there a way to just tell the response parsing mechanism that I want it to match the fields in the object with the fields in the response, as Jackson would?  I can fall back to response.getContent() to get the InputStream and then use Jackon's ObjectMapper to deserialize, but that feels pretty close to just doing everything myself and not using google-http-client at all.
Reply all
Reply to author
Forward
0 new messages