Getting exception below while using Jackson api.See attached image.
class BlogSwiftJSONUtil {
static String parseToJSON(Object object){
ObjectMapper objectMapper = new ObjectMapper()
return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(object)
}
}
Line below I have used to parse output json on all actions.
render contentType: 'application/json', text:BlogSwiftJSONUtil.parseToJSON(listAllResources(params))
Added jackson library in BuildConfig.groovy is as below:
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// runtime 'mysql:mysql-connector-java:5.1.29'
// runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
runtime 'com.fasterxml.jackson.core:jackson-core:2.0.4'
runtime 'com.fasterxml.jackson.core:jackson-databind:2.0.4'
runtime 'com.fasterxml.jackson.core:jackson-annotations:2.0.4'
}
Anyone why am I getting this exception.
Below are some findings from me:
- if I pass map like object.properties rather than object itself it works.
- It seems that it's also trying to serialize validation errors as well.
Any helps would be worth.
Please let me know if I could share any other details.
Thanks!