Jackson: how to treat {type: xx}?

I have the following json:

{"resourceWithType":
  {"parentId":0,
   "pluginId":0,
   "pluginName":"Platforms",
   "resourceId":10001,
   "resourceName":"snert",
   "typeId":10057,
   "typeName":"Mac OS X"
  }
}

And class

public class ResourceWithType {

    String resourceName;
    int resourceId;
    String typeName;

with all recipients and setters, etc.

The above JSON was actually created through RESTeasy and the Jettison provider, where the class was tagged @XmlRootElement.

When I try to deserialize the above JSON via

ObjectMapper mapper=new ObjectMapper();
ResourceWithType rwt = mapper.readValue(json,ResourceWithType.class);

Unable to complete

06-13 11:07:55.360: WARN/System.err(26040): 
   org.codehaus.jackson.map.exc.UnrecognizedPropertyException: 
   Unrecognized field "resourceWithType" 
   (Class org.rhq.core.domain.rest.ResourceWithType), 
   not marked as ignorable

Which view is clear.

How can I tell Jackson that the embedded "resourceWithType" is actually a deserialization class in?

Another option is to report that the release should not include this type - how?

+3
source share
2 answers

, TreeModel API, ( ), ( API)?

+2

- ; , :

class {
    public ResourceWithType resourceWithType;
}

. , ( "resourceWithType" ).

+3

All Articles