2

When using Marshallers, I could use something like:

JSON.registerObjectMarshaller(Date) {
    return it?.format("yyyy-MM-dd'T'HH:mm:ss")
}

and it would make all Date objects render to JSON with that format. Is there an equivalent I can use with JSON Views to display Date objects?

Anonymous1
  • 3,877
  • 3
  • 28
  • 42

1 Answers1

0

The format used for Date is hard coded in JsonOutput.java (https://github.com/grails/grails-views/blob/master/json/src/main/groovy/grails/plugin/json/builder/JsonOutput.java)

I've created an issue about this https://github.com/grails/grails-views/issues/92

A temporary workaround is to duplicate JsonOutput.java and place it in src/main/grails/plugin/json/builder with the format modified to your need.