• Post Reply Bookmark Topic Watch Topic
  • New Topic

Jackson/JSON 2.2.3 serializes but does not deserialize properly.  RSS feed

 
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My GET requests for my spring REST servlet are working to properly display my class guest.

Here is an example:


However, when doing a post, everything is deserialized as having null fields. I experimented with removing quotes on the id field. I omitted all but the name field. Nothing makes jackson behave. I have a complete set of setters and getters for class guest as well as a complete set of constructors.
Jackson always calls the default constructor and then fails to use any of my setters!
How do I make jackson call my setName? Or perhaps use a constructor to set the value?



 
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does your controller methods look like?
 
Siegfried Heintze
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I found the problem!
The spring @ResponseBody uses JSON for get but uses URL Encoding for POST.
See the jQuery POST method for http://codetutr.com/2013/04/09/spring-mvc-easy-rest-based-json-services-with-responsebody/
Why the inconsistency? This drove me nuts!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!