2012-09-07 48 views
1

jibx是否支持json?或者有没有办法使用jibx编组来支持json格式? 我正在尝试使用json格式支持和alsi jibx编组支持来实现休息服务。jibx是否支持json?

回答

1

对不起,JiBX不支持json编组/解组。 我会建议使用JiBX的XML部分,并看看这个stackoverflow主题将dom转换为json。

1

有可能通过使用抛弃生成使用JiBX JSON:

StringWriter pw = new StringWriter(16384); 
XMLStreamWriter w = new MappedXMLStreamWriter(mnc, pw); 

// Generate XML. 
IMarshallingContext mctx = bfact.createMarshallingContext(); 
mctx.setXmlWriter(
    new StAXWriter(bfact.getNamespaces(), w)); 

w.writeStartDocument(); 
mctx.marshalDocument(obj, "UTF-8", true); 
w.writeEndDocument(); 

w.close(); 
pw.close(); 

return pw.toString(); 

然而,所有的XML属性会出来为字符串。