Grails error when customizing JSON output -
i modifying way grails converts object json. add in bootstrap.groovy:
json.registerobjectmarshaller(ufile) { def returnarray = [:] returnarray['id'] = it.id returnarray['docname'] = it.docname returnarray['fullpath'] = it.fullpath returnarray['uploaddate'] = it.uploaddate returnarray['mime'] = it.mime returnarray['size'] = it.size returnarray['eval'] = it.eval return returnarray }
i ufile list database , try convert json:
def files = ufile.findall() def json = files json
and have error:
class org.codehaus.groovy.grails.web.converters.marshaller.json.genericjavabeanmarshaller can not access member of class org.springframework.beans.generictypeawarepropertydescriptor modifiers "public". stacktrace follows: message: class org.codehaus.groovy.grails.web.converters.marshaller.json.genericjavabeanmarshaller can not access member of class org.springframework.beans.generictypeawarepropertydescriptor modifiers "public"
then when restart server error disappears , works should.
this ufile domain class:
class ufile { string docname string fullpath integer size string mime date uploaddate = new date() boolean item static hasmany = [metadatavalue : metadatavalue] static belongsto = [user: user] static mapping = { } static transients = ['eval'] static constraints = { docname blank: false, nullable: false metadatavalue nullable: true fullpath blank: false, nullable: false size blank: false, nullable: false mime blank: false user blank: false, nullable: false item nullable: false size validator: { size -> if ( size > 536870912 ) return false } } def geteval(){ def total = 0 if (user) { user.validationops.each { op -> def mv = metadatavalue.find { mv -> mv.metadata.element == op.metadata.element } total += (mv ? 1 : 0) * op.value } return user.totalpesos() == 0 ? 0 : total / user.totalpesos() } return total } }
anyone have idea why error? in advance !
Comments
Post a Comment