Reputation: 187
I have a Modules class that contains a list of Module, the normal jackson json would look like:
{
"modules" : [
{
"name" : "module1" ,
"file" : "file1"
},
{
"name" : "module2" ,
"file" : "file2"
}
]
}
But I need the json file to be like this:
{
"modules" : {
"module1" : {
"file" : "file1"
},
"module2" : {
"file" : "file2"
}
}
}
Is there an easy way to configure/construct the pojo classes to achieve what I want without a custom deserializer? Thanks
Upvotes: 0
Views: 366
Reputation: 37506
It's been a while since I've done anything with Jackson, but if you store the objects in a HashMap<String, ObjectType>
that might do it. Otherwise yes, a custom deserializer would be necessary.
Upvotes: 2