I'm trying to figure out how to deserialize and validate nested objects in JSON request into a Grails 2.1.1 command object.
Currently I have a command object in my controller that has a few basic properties and then list of domain objects,
protected static class CustomCommand {
String name
String description
List<DomainObject> objs
}
And a JSON body to my POST request,
{
name: 'test name',
description: 'test description',
objs: [
{
name: 'test sub object',
description: 'test description'
}
]
}
I'm seeing the command object created with an empty array. Any idea how I can get the sub objects my in JSON body to deserialize into the command object and then validate them?
Previously I've worked around this by manually creating an object from the parameter map and validating that directly, but that feels like a workaround that isn't taking advantage of everything Grails offers.
I never got this to work under Grails 2.1.1, but apparently this was fixed in Grails 2.3,