deserialize nested JSON objects in Spring MVC with Jackson

NOTE: I had to use Jackson 2.2 to get this working. Jackson 1.9 did not cut it.

API needs

The VenueObj has a single LocationObj field, called location. The LocationObj field needs to be set when deserializing a full VenueObj JSON POST payload, and the location field needs to be serialized when the VenueObj is serialized. POST mapping - Controller

@RequestMapping(value = RequestMappingConstants.kApiVenues, method = RequestMethod.POST)
protected @ResponseBody long putVenue(@RequestBody final VenueObj theVenueObj, final Principal thePrincipal, final HttpServletResponse response);

Note the annotation driven mapping. May need to wire up your spring-dispatcher-servlet.xml. constructor - JSON de/serialization and ORM

public VenueObj(@JsonProperty(VenueObj.NAME) final String theName,
                @JsonProperty(VenueObj.LOCATION) final LocationObj theLocation,
                @JsonProperty(VenueObj.PHONE) final String thePhone,
                @JsonProperty(VenueObj.WEB) final String theWeb) { = theName;
    this.location = theLocation; = thePhone;
    this.web = theWeb;

All other public constructors should be annotated with @JsonIgnore to prevent the Jackson process from attempting to deserialize with the incorrect one and spitting up. getters/setters - JSON de/serialization and ORM

public float getLat() {

public float getLon() {
    return this.lon;


public void setLat(final float theLat) { = theLat;

public void setLon(final float theLon) {
    this.lon = theLon;

The LocationObj class is a constructor-less cacophony of getters and setters, with a few private data manipulation methods.


And now the service should be able to make sense of incoming JSON like:

    "name":"Eldora Mountain Resort",
    "phone":"(303) 440-8700",

Further Reading