Skip to content

Instantly share code, notes, and snippets.

@rodrigodealer
Created February 15, 2012 14:02
Show Gist options
  • Save rodrigodealer/1835923 to your computer and use it in GitHub Desktop.
Save rodrigodealer/1835923 to your computer and use it in GitHub Desktop.
Json serialization for vraptor
package br.com.pordotom.util;
import br.com.caelum.vraptor.interceptor.TypeNameExtractor;
import br.com.caelum.vraptor.ioc.Component;
import br.com.caelum.vraptor.serialization.ProxyInitializer;
import br.com.caelum.vraptor.serialization.xstream.XStreamBuilder;
import br.com.caelum.vraptor.serialization.xstream.XStreamJSONSerialization;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.basic.DateConverter;
import javax.servlet.http.HttpServletResponse;
@Component
public class CustomJSONSerialization extends XStreamJSONSerialization {
public CustomJSONSerialization(HttpServletResponse response, TypeNameExtractor extractor, ProxyInitializer initializer, XStreamBuilder builder) {
super(response, extractor, initializer, builder);
}
@Override
public XStream getXStream() {
XStream xstream = super.getXStream();
xstream.registerConverter(new DateConverter("dd/MM/yyyy HH:mm:ss", new String[0]));
return xstream;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment