• 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Jackson - expecting list of strings but receiving list of complex objects

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically I have a map class with:

List<String> allergies;
A JSON like this is expected:

[“Allergie1”,”Allergie2”]
But if JSON is something like this is not failing:

[{“name”:“Allergie1”},{“name”:“Allergie1”}]
and transforming to the following list:

["{", "name", "Allergie1", "}","{", "name", "Allergie1", "}"]
Using org.codehaus.jackson.map.ObjectMapper.readValue method. Jackson 1.9.13. I'd like to know why deserialization is not failing.

Thanks in advance!
 
Sheriff
Posts: 21775
103
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

How are you deserializing this? And what is the actual result of deserializing this?

(You may want to consider switching to Jackson 2 though; Jackson 1 is quite old and no longer maintained.)
 
Facundo Barcelo
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob,
using org.codehaus.jackson.map.ObjectMapper.readValue. I am creating an ObjectMapper object with no any special option.

Thanks,
Facundo
 
Rob Spoor
Sheriff
Posts: 21775
103
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show the full method call?
 
Facundo Barcelo
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fixed the issue going to a newer version of Jakson.

Thanks all!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!