Reputation: 319
Is it possible to deserialize the example below using Jackson?
public class A extends HashMap<String,String> {
//No other methods here for now
}
....
JSON Looks like this:
{"something":
{
"entry":
[
{"key":"one", "value":"avalue"},
{"key":"two", "value":"bvalue"}
]
}
}
...
At this time I'm getting error saying: Unrecognized Property Exception for entry.
Any help would be greatly appreciated.
Upvotes: 0
Views: 96
Reputation: 4086
First, your json is wrong, but I think I see what you're trying.
No it's not possible. HashMap<String,String>
implies your object contains only top level string properties like:
{
"something": "value",
"somethingelse": "value2",
"someAdditionalThing": "value3"
}
To deserialize that you probably need to have a more strongly typed object. Jackson is falling over trying to turn:
{
"entry":
[
{"key":"one", "value":"avalue"},
{"key":"two", "value":"bvalue"}
]
}
Into a string.
Upvotes: 2