marshallers.add(new org.grails.web.converters.marshaller.json.CollectionMarshaller());
marshallers.add(new org.grails.web.converters.marshaller.json.MapMarshaller());
marshallers.add(new org.grails.web.converters.marshaller.json.EnumMarshaller());
marshallers.add(new org.grails.web.converters.marshaller.ProxyUnwrappingMarshaller<JSON>());
DeprecatedGrailsConfig grailsConfig = new DeprecatedGrailsConfig(grailsApplication);
if ("javascript".equals(grailsConfig.get("grails.converters.json.date", "default", Arrays.asList("javascript", "default")))) {
LOG.debug("Using Javascript JSON Date Marshaller.");
marshallers.add(new org.grails.web.converters.marshaller.json.JavascriptDateMarshaller());
}
else {
LOG.debug("Using default JSON Date Marshaller");
marshallers.add(new org.grails.web.converters.marshaller.json.DateMarshaller());
}
marshallers.add(new org.grails.web.converters.marshaller.json.ToStringBeanMarshaller());
boolean includeDomainVersion = includeDomainVersionProperty(grailsConfig,"json");
ProxyHandler proxyHandler = getProxyHandler();
if (grailsConfig.get("grails.converters.json.default.deep", false)) {
LOG.debug("Using DeepDomainClassMarshaller as default.");
marshallers.add(new org.grails.web.converters.marshaller.json.DeepDomainClassMarshaller(includeDomainVersion, proxyHandler, grailsApplication));
}
else {
marshallers.add(new org.grails.web.converters.marshaller.json.DomainClassMarshaller(includeDomainVersion, proxyHandler, grailsApplication));
}
marshallers.add(new org.grails.web.converters.marshaller.json.GroovyBeanMarshaller());
marshallers.add(new org.grails.web.converters.marshaller.json.GenericJavaBeanMarshaller());
DefaultConverterConfiguration<JSON> cfg = new DefaultConverterConfiguration<JSON>(marshallers, proxyHandler);
cfg.setEncoding(grailsConfig.get("grails.converters.encoding", "UTF-8"));
String defaultCirRefBehaviour = grailsConfig.get("grails.converters.default.circular.reference.behaviour", "DEFAULT");
cfg.setCircularReferenceBehaviour(Converter.CircularReferenceBehaviour.valueOf(
grailsConfig.get("grails.converters.json.circular.reference.behaviour",
defaultCirRefBehaviour, Converter.CircularReferenceBehaviour.allowedValues())));
Boolean defaultPrettyPrint = grailsConfig.get("grails.converters.default.pretty.print", false);
Boolean prettyPrint = grailsConfig.get("grails.converters.json.pretty.print", defaultPrettyPrint);
cfg.setPrettyPrint(prettyPrint);
cfg.setCacheObjectMarshallerByClass(grailsConfig.get("grails.converters.json.cacheObjectMarshallerSelectionByClass", true));
registerObjectMarshallersFromApplicationContext(cfg, JSON.class);
ConvertersConfigurationHolder.setDefaultConfiguration(JSON.class, new ChainedConverterConfiguration<JSON>(cfg, proxyHandler));
}