I don't know whether Jackson's JAX-RS support allows you to plug in a 
custom ObjectMapper.  It would be something we'd have to add if so.

A solution would probably implement a JAX-RS ContextResolver.

On 2/21/12 1:58 AM, Richard Kennard wrote:
> Hi guys,
> I'm confused as to the recommended approach to deserializing non-standard 
> JSON types. In my case there's a Long embedded in the JSON tree but I want to
> deserialize it to a JPA entity (based on using the Long as an id into the 
> database)
> I have looked a variety of documentation, none seem very appealing. Here is 
> my thought process:
> 1. The current Exception I get is "JsonMappingException: Can not construct 
> instance of ..., problem: no suitable creator method found". I guess I could 
> add
> a constructor to my JPA entity that takes a Long , but I'd rather not have 
> the entity itself accessing the EntityManager. I'd rather have an external 
> DTO.
> 2. I can put @JsonSerialize on my JPA entity, and point it to a serializer 
> class. But again I'd rather not tie my entity to its DTO.
> 3. I can use @Provider and a custom MessageBodyReader, but this appears to 
> want to read the entire HTTP message, not just part of the JSON tree?
> 4. I can register a custom Jackson serializer as explained here 
> http://wiki.fasterxml.com/JacksonHowToCustomSerializers. But to do that I'll 
> need a custom
> ObjectMapper provider as explained here 
> http://jersey.576304.n2.nabble.com/Customizing-ObjectMapper-td6234597.html 
> And I'm very unsure what my 'new
> SimpleModule' should look like?
> Can anyone help with a 'best practice' recommendation?
> Regards,
> Richard.
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users

Bill Burke
JBoss, a division of Red Hat

Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
Resteasy-users mailing list

Reply via email to