• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Deserialize an Array within an object with jackson

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have the following JSON file:



I'm able to deserialize the objects in the array and their variables but If I include other arrays as object variables it does not work. These objects should be Map objects, here is the class:



My intention is to fill an Array of map objects with the information in the json file, I'm doing it this way:



But this only works if I delete the nested arrays, otherwise it gives me an error telling that 'Item' and 'Door' tokens weren't recognized. Any hint? Sorry if it is obvious I'm new to Jackson. Thanks in advance
 
Sheriff
Posts: 6163
163
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm seeing a couple of things.

First, don't name your class after another well-known class, like Map.  Think of some other name for the class.

Is Maps a variable name?  Those should start with a lowercase letter.

What type is the variable mapper?
 
Carlos Roma
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:I'm seeing a couple of things.

First, don't name your class after another well-known class, like Map.  Think of some other name for the class.

Is Maps a variable name?  Those should start with a lowercase letter.

What type is the variable mapper?



Is an ObjectMapper object, comes from the Jackson library, sorry I forgot to include it's creation. Thanks for the tips.
 
grapes are vegan food pellets. Eat this tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!