Class JSONWriterRecord

All Implemented Interfaces:
AbstractMarshalRecord<CoreAbstractSession,CoreField,XMLMarshaller,NamespaceResolver>, MarshalRecord<CoreAbstractSession,CoreField,XMLMarshaller,NamespaceResolver>, XMLRecord<CoreAbstractSession>
Direct Known Subclasses:
JSONFormattedWriterRecord

public class JSONWriterRecord extends MarshalRecord<XMLMarshaller>

Use this type of MarshalRecord when the marshal target is a Writer and the JSON should not be formatted with carriage returns or indenting.

XMLContext xmlContext = new XMLContext("session-name");
XMLMarshaller xmlMarshaller = xmlContext.createMarshaller();
JSONRecord jsonWriterRecord = new JSONWriterRecord();
jsonWriterRecord.setWriter(myWriter);
xmlMarshaller.marshal(myObject, jsonWriterRecord);

If the marshal(Writer) and setMediaType(MediaType.APPLICATION_JSON) and setFormattedOutput(false) method is called on XMLMarshaller, then the Writer is automatically wrapped in a JSONWriterRecord.

XMLContext xmlContext = new XMLContext("session-name");
XMLMarshaller xmlMarshaller = xmlContext.createMarshaller();
xmlMarshaller.setMediaType(MediaType.APPLICATION_JSON); xmlMarshaller xmlMarshaller.setFormattedOutput(false);
xmlMarshaller.marshal(myObject, myWriter);

See Also: