XML : Grails 3 - Marshaller with XML

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,                      ]                  }              })    

Kindly suggest me, how to do marshalling for xml response.

No comments:

Post a Comment