users@jersey.java.net

[Jersey] ClientResponse.getEntity has problem with _at_JsonTypeInfo annotation

From: Pengfei Di <pengfei.di_at_match2blue.com>
Date: Thu, 24 Mar 2011 10:29:52 +0100

Hello,

I have some problem when I use ClientResponse.getEntity to parse a jaxb
class from a JSON representation, if @JsonTypeInfo annotation is applied.
Here is the code with problem:

@JsonTypeInfo(use = Id.NAME, include = As.WRAPPER_OBJECT)
@XmlRootElement
public class MyTest
{
private int code;
private String msg;
//setter and getter
}

The Json string looks like:
{"MyTest":{"code":207,"msg":"blah blah"}}
and the parsed result of MyTest contains either 0 or null.


However, if I remove the include part of the @JsonTypeInfo, there is no
problem any more, and the Json string looks like:
{"@type":"MyTest","code":207,"msg":"blah blah"}

Thanks a lot for any help!

Pengfei