[AJUDA] Problema XStream Vraptor

Fala…

Estou tentando modificar a serialização json do vraptor a partir do XSTREAM, porem uma coisa estranha é que ele está me retornando a serialização do HashMap com um @ na frente.
Alguem poderia me ajudar. Segue os codigos abaixo.

[code]public class DefaultMapConverter implements Converter {

@Override
public boolean canConvert(Class clazz) {
	return Map.class.isAssignableFrom(clazz);
}

@Override
public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext context) {
	writer.startNode("map");
	Map<?,?> map = (Map<?,?>) obj;
	for (Entry<?,?> entry : map.entrySet()) {
		writer.addAttribute(entry.getKey().toString(), entry.getValue().toString());
	}
	writer.endNode();
}

@Override
public Object unmarshal(HierarchicalStreamReader arg0, UnmarshallingContext arg1) {
	return null;
}

}[/code]

[code]@Component
public class CustomJSONSerialization extends XStreamJSONSerialization {

private final HttpServletResponse response;  

public CustomJSONSerialization(HttpServletResponse response,TypeNameExtractor extractor, ProxyInitializer initializer) {
	super(response, extractor, initializer);
	this.response = response;
}



/*public CustomJSONSerialization(HttpServletResponse response, TypeNameExtractor extractor) {  
	this.response = response;
	this.extractor = extractor;	
} */

@Override
public XStream getXStream() {
	XStream xstream = super.getXStream();
    xstream.registerConverter(new DefaultMapConverter());
    return xstream;
}

}[/code]

[code]public class MessageResult {
private final boolean success;
private final Map<String,String> attrs;

public MessageResult(boolean success) {
    this.success = success;
    this.attrs = new HashMap<String, String>();
}

public MessageResult with(String key, String value) {
    this.attrs.put(key, value);
    return this;
}

}[/code]

/*Controller*/ result.use(Results.json()).from(new MessageResult(true) .with("message","ok") .with("total", "x")).include("attrs") .serialize();

/Resultado/

{“messageResult”: {
“success”: true,
“attrs”: [
{
"@total": “x”,
"@message": “ok”
}
]
}}

tenta isso no Map converter:

for (Entry<?,?> entry : map.entrySet()) {  
   writer.startNode(entry.getKey().toString());
   writer.setValue(entry.getValue().toString());  
   writer.endNode();
} 

[]'s

Perfeito… Muito Obrigado.

Para o pessoal que tiver o mesmo problema, basta alterar o código com o trecho passado pelo Lucas.

abs