I am deserializing a Json object which contains as one of it's properties an array of objects, like so:
{
name: 'abc',
symbols: {
{ a: '1', b: 'test'}, { a: '2', b: 'test'}, { a: '3', b: 'test'} ...
]
}
If I deserialize into a class like this, it works fine:
class MyContainer {
private String name;
private Symbol[] symbols;
}
However, I get many items in the symbols array, and would like to deserialize into a map instead, where the key is the a
property of each symbol, and the value is the symbol object itself, as to have them indexed by that property for fast lookups later:
class MyContainer {
private String name;
private Map<String, Symbol> symbols;
}
I can assure the a
properties in the array always have a unique value.
I saw many posts about maps but none seemed to cover this use case, which is quite common for me.
How can I accomplish this with Jackson?
Thanks!