Does jibx support json? or is there a way to support json format using jibx marshalling? I am trying to implement a rest service with json format support and alsi jibx marshalling support.
Asked
Active
Viewed 642 times
2 Answers
1
Sorry, JiBX does not support json marshalling/unmarshalling.
I would suggest using JiBX for the XML part and take a look at this stackoverflow subject for converting dom to json.
Don

Community
- 1
- 1

Don Corley
- 496
- 2
- 7
1
It's possible to generate JSON with JiBX by using Jettison:
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();
However, all of the XML attributes will come out as strings.

Alex Hayward
- 216
- 1
- 4