• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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

 
Ranch Hand
Posts: 420
  • 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: 420
  • 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!
 
Yes, my master! Here is the tiny ad you asked for:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!