I have grails 3.1 application.
Below is the code for customizing the elements, which uses JSON marshaller, which works perfectly.
JSON.createNamedConfig("memeListView", {
JSON.registerObjectMarshaller(Meme) { Meme memeIns ->
return [
caption: memeIns.caption,
likeCount: memeIns.likeCount,
]
}
})
But, I have tried the above code for XML marshaller, but it displays entire object attributes, instead of required. Below is the code for XML marshalling.
XML.createNamedConfig("memeListView", {
XML.registerObjectMarshaller(Meme) { Meme memeIns ->
return [
caption: memeIns.caption,
likeCount: memeIns.likeCount,
]
}
})
In action part
JSON.use('memeListView'){
render memesList as JSON
}
Kindly suggest me, how to do marshalling for xml response.