Skip to content

Instantly share code, notes, and snippets.

@atomsfat
Created January 28, 2014 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atomsfat/8673440 to your computer and use it in GitHub Desktop.
Save atomsfat/8673440 to your computer and use it in GitHub Desktop.
Fat grails domain class with custom marshaller
package atoms.fat.media
import grails.converters.JSON
import org.joda.time.DateTime
class Media implements Serializable {
String url
String name
DateTime dateCreated
DateTime lastUpdated
static constraints = {
url blank: false, url: true, maxSize: 500
name nullable: true, mazSize: 100
dateCreated display: false, nullable: true
lastUpdated display: false, nullable: true
}
//here custom marshaller
static marshaller = {
JSON.registerObjectMarshaller(Media, 1) { m ->
return [
id: m.id,
url: m.url,
name: m.name
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment