/** * Construct a JettisonMappedXmlDriver with configuration. This constructor has been added * by special request of Jettison users to support JSON generated by older Jettison * versions. if the driver is setup to ignore the XStream hints for JSON arrays, there is * neither support from XStream's side nor are there any tests to ensure this mode. * * @param config the Jettison configuration * @param useSerializeAsArray flag to use XStream's hints for collections and arrays * @since 1.4 */ public JettisonMappedXmlDriver(final Configuration config, final boolean useSerializeAsArray) { mof = new MappedXMLOutputFactory(config); mif = new MappedXMLInputFactory(config); convention = new MappedNamespaceConvention(config); this.useSerializeAsArray = useSerializeAsArray; }
public static XMLStreamWriter createWriter(final Writer writer, final JettisonConfig config) throws IOException { switch (config.getNotation()) { case BADGERFISH: return new BadgerFishXMLStreamWriter(writer); case MAPPED_JETTISON: Configuration jmConfig; if (null == config.getXml2JsonNs()) { jmConfig = new Configuration(); } else { jmConfig = new Configuration(config.getXml2JsonNs()); } final MappedXMLStreamWriter result = new MappedXMLStreamWriter(new MappedNamespaceConvention(jmConfig), writer); for (String array : config.getArrayElements()) { result.serializeAsArray(array); } return result; default: return null; } }
public static XMLStreamReader createReader(final Reader reader, final JettisonConfig config) throws XMLStreamException { Reader nonEmptyReader = ensureNonEmptyReader(reader); switch (config.getNotation()) { case MAPPED_JETTISON: try { Configuration jmConfig; if (null == config.getXml2JsonNs()) { jmConfig = new Configuration(); } else { jmConfig = new Configuration(config.getXml2JsonNs()); } return new MappedXMLStreamReader( new JSONObject(new JSONTokener(ReaderWriter.readFromAsString(nonEmptyReader))), new MappedNamespaceConvention(jmConfig)); } catch (Exception ex) { throw new XMLStreamException(ex); } case BADGERFISH: try { return new BadgerFishXMLStreamReader( new JSONObject(new JSONTokener(ReaderWriter.readFromAsString(nonEmptyReader)))); } catch (Exception ex) { throw new XMLStreamException(ex); } } // This should not occur throw new IllegalArgumentException("Unknown JSON config"); }
public MappedXMLStreamReader(JSONObject obj) throws JSONException, XMLStreamException { this(obj, new MappedNamespaceConvention()); }
public MappedXMLOutputFactory(Configuration config) { this.convention = new MappedNamespaceConvention(config); }
public MappedXMLInputFactory(Configuration config) { this.convention = new MappedNamespaceConvention(config); }
public static XMLStreamReader createReader(final Reader reader, final JSONConfiguration config, final String rootName, final Class<?> expectedType, final JAXBContext jaxbContext, final boolean readingList) throws XMLStreamException { Reader nonEmptyReader = ensureNonEmptyReader(reader); switch (config.getNotation()) { case NATURAL: case MAPPED: return JsonXmlStreamReader.create(nonEmptyReader, config, rootName, expectedType, jaxbContext, readingList); case MAPPED_JETTISON: try { Configuration jmConfig; if (null == config.getXml2JsonNs()) { jmConfig = new Configuration(); } else { jmConfig = new Configuration(config.getXml2JsonNs()); } return new MappedXMLStreamReader( new JSONObject(new JSONTokener(ReaderWriter.readFromAsString(nonEmptyReader))), new MappedNamespaceConvention(jmConfig)); } catch (Exception ex) { throw new XMLStreamException(ex); } case BADGERFISH: try { return new BadgerFishXMLStreamReader(new JSONObject(new JSONTokener(ReaderWriter.readFromAsString(nonEmptyReader)))); } catch (Exception ex) { throw new XMLStreamException(ex); } } // This should not occur throw new IllegalArgumentException("Unknown JSON config"); }
public MappedXMLStreamReader(JSONObject obj) throws JSONException, XMLStreamException { this(obj, new MappedNamespaceConvention()); }
public MappedXMLInputFactory(Configuration config) { this.convention = new MappedNamespaceConvention(config); }
public MappedXMLOutputFactory(Configuration config) { this.convention = new MappedNamespaceConvention(config); }
jmConfig = new Configuration(config.getXml2JsonNs()); return new MappedXMLStreamWriter(new MappedNamespaceConvention(jmConfig), writer); default: return null;
public JettisonMappedMarshaller(JAXBContext context, Map<String, String> xmlToJSON, List<String> attributeMapping, List<String> ignoredElements) throws JAXBException { marshaller = context.createMarshaller(); Configuration config = new Configuration(xmlToJSON, attributeMapping, ignoredElements); convention = new MappedNamespaceConvention(config); }
public JettisonMappedUnmarshaller(JAXBContext context, Map<String, String> xmlToJSON, List<String> attributeMapping, List<String> ignoredElements) throws JAXBException { unmarshaller = context.createUnmarshaller(); Configuration config = new Configuration(xmlToJSON, attributeMapping, ignoredElements); convention = new MappedNamespaceConvention(config); }
public JettisonMappedContext(Map<String, String> xmlnsToJson, List<QName> attributesAsElements, List<QName> ignoredElements, Class... classes) { Configuration config = new Configuration(xmlnsToJson, attributesAsElements, ignoredElements); convention = new MappedNamespaceConvention(config); try { context = JAXBContext.newInstance(classes); } catch (JAXBException e) { throw new RuntimeException(e); } }
JAXBContext jc = JAXBContext.newInstance(Customer.class); JSONObject obj = new JSONObject("{\"customer\":{\"id\":123,\"first-name\":\"Jane\",\"last-name\":\"Doe\",\"address\":{\"street\":\"123 A Street\"},\"phone-number\":[{\"@type\":\"work\",\"$\":\"555-1111\"},{\"@type\":\"cell\",\"$\":\"555-2222\"}]}}"); Configuration config = new Configuration(); MappedNamespaceConvention con = new MappedNamespaceConvention(config); XMLStreamReader xmlStreamReader = new MappedXMLStreamReader(obj, con); Unmarshaller unmarshaller = jc.createUnmarshaller(); Customer customer = (Customer) unmarshaller.unmarshal(xmlStreamReader);
public JettisonMappedXmlDriver(final Configuration config, final boolean useSerializeAsArray) { mof = new MappedXMLOutputFactory(config); mif = new MappedXMLInputFactory(config); convention = new MappedNamespaceConvention(config); this.useSerializeAsArray = useSerializeAsArray; }
/** * Construct a JettisonMappedXmlDriver with configuration. This constructor has been added * by special request of Jettison users to support JSON generated by older Jettison * versions. if the driver is setup to ignore the XStream hints for JSON arrays, there is * neither support from XStream's side nor are there any tests to ensure this mode. * * @param config the Jettison configuration * @param useSerializeAsArray flag to use XStream's hints for collections and arrays * @since 1.4 */ public JettisonMappedXmlDriver(final Configuration config, final boolean useSerializeAsArray) { mof = new MappedXMLOutputFactory(config); mif = new MappedXMLInputFactory(config); convention = new MappedNamespaceConvention(config); this.useSerializeAsArray = useSerializeAsArray; }
/** * Construct a JettisonMappedXmlDriver with configuration. This constructor has been added * by special request of Jettison users to support JSON generated by older Jettison * versions. if the driver is setup to ignore the XStream hints for JSON arrays, there is * neither support from XStream's side nor are there any tests to ensure this mode. * * @param config the Jettison configuration * @param useSerializeAsArray flag to use XStream's hints for collections and arrays * @since 1.4 */ public JettisonMappedXmlDriver(final Configuration config, final boolean useSerializeAsArray) { mof = new MappedXMLOutputFactory(config); mif = new MappedXMLInputFactory(config); convention = new MappedNamespaceConvention(config); this.useSerializeAsArray = useSerializeAsArray; }
public JettisonMappedXmlDriver() { final HashMap nstjsons = new HashMap(); final Configuration config = new Configuration(nstjsons); mof = new MappedXMLOutputFactory(config); mif = new MappedXMLInputFactory(config); convention = new MappedNamespaceConvention(config); }
public JettisonMappedXmlDriver() { final HashMap nstjsons = new HashMap(); final Configuration config = new Configuration(nstjsons); mof = new MappedXMLOutputFactory(config); mif = new MappedXMLInputFactory(config); convention = new MappedNamespaceConvention(config); }