Reputation: 5687
My json string has an array at the top level. E.g.:
[
{...},
{...}
]
And I'm using jackson to deserialize it like so:
val parser = mapper.getFactory.createParser(json)
val mylist = mapper.readValue(parser, classOf[List[Track]])
The trouble is that the values of the list are coming out as HashMap
rather than Track
objects, even though I'm specifying that this is a generic list of Track
s. On the console:
mylist.isInstanceOf[List[Track]]
> true
mylist.head.isInstanceOf[Track]
> false
mylist.head.isInstanceOf[HashMap]
> true
How can I do to make sure jackson returns Track objects instead of HashMap?
Upvotes: 1
Views: 973