Package com.fasterxml.jackson.dataformat.xml

Examples of com.fasterxml.jackson.dataformat.xml.XmlMapper.configure()


    }

    private static XmlMapper getXmlMapper() {
        XmlMapper mapper = new XmlMapper();
        mapper.setPropertyNamingStrategy(PropertyNamingStrategy.PASCAL_CASE_TO_CAMEL_CASE);
        mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
        mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
        mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        return mapper;
    }
View Full Code Here


    // [Issue#48]: ObjectMapper.copy()
    public void testMapperCopy()
    {
        XmlMapper mapper1 = new XmlMapper();
        mapper1.setXMLTextElementName("foo");
        mapper1.configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true);
       
        XmlMapper mapper2 = mapper1.copy();
        assertNotSame(mapper1, mapper2);
        XmlFactory xf1 = mapper1.getFactory();
        XmlFactory xf2 = mapper2.getFactory();
View Full Code Here

     */
   
    public void testXml10Declaration() throws Exception
    {
        XmlMapper mapper = new XmlMapper();
        mapper.configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true);
        String xml = mapper.writeValueAsString(new StringBean("123"));
        assertEquals(xml, "<?xml version='1.0' encoding='UTF-8'?><StringBean><text>123</text></StringBean>");
    }

    public void testXml11Declaration() throws Exception
View Full Code Here

    }

    public void testXml11Declaration() throws Exception
    {
        XmlMapper mapper = new XmlMapper();
        mapper.configure(ToXmlGenerator.Feature.WRITE_XML_1_1, true);
        String xml = mapper.writeValueAsString(new StringBean("abcd"));
        assertEquals(xml, "<?xml version='1.1' encoding='UTF-8'?><StringBean><text>abcd</text></StringBean>");
    }
   
}
View Full Code Here

        foo.bars = new Bar[] { bar1, bar2 };

        ObjectMapper xmlMapper = new XmlMapper();

        xmlMapper.configure(MapperFeature.AUTO_DETECT_FIELDS, false );
        xmlMapper.configure(MapperFeature.AUTO_DETECT_GETTERS, false );
        xmlMapper.configure(MapperFeature.AUTO_DETECT_IS_GETTERS, false );
        xmlMapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false );

        String xml = xmlMapper.writerWithView(RestrictedView.class).writeValueAsString(foo);
View Full Code Here

        foo.bars = new Bar[] { bar1, bar2 };

        ObjectMapper xmlMapper = new XmlMapper();

        xmlMapper.configure(MapperFeature.AUTO_DETECT_FIELDS, false );
        xmlMapper.configure(MapperFeature.AUTO_DETECT_GETTERS, false );
        xmlMapper.configure(MapperFeature.AUTO_DETECT_IS_GETTERS, false );
        xmlMapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false );

        String xml = xmlMapper.writerWithView(RestrictedView.class).writeValueAsString(foo);
       
View Full Code Here

        ObjectMapper xmlMapper = new XmlMapper();

        xmlMapper.configure(MapperFeature.AUTO_DETECT_FIELDS, false );
        xmlMapper.configure(MapperFeature.AUTO_DETECT_GETTERS, false );
        xmlMapper.configure(MapperFeature.AUTO_DETECT_IS_GETTERS, false );
        xmlMapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false );

        String xml = xmlMapper.writerWithView(RestrictedView.class).writeValueAsString(foo);
       
        // views not used for deserialization
View Full Code Here

        ObjectMapper xmlMapper = new XmlMapper();

        xmlMapper.configure(MapperFeature.AUTO_DETECT_FIELDS, false );
        xmlMapper.configure(MapperFeature.AUTO_DETECT_GETTERS, false );
        xmlMapper.configure(MapperFeature.AUTO_DETECT_IS_GETTERS, false );
        xmlMapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false );

        String xml = xmlMapper.writerWithView(RestrictedView.class).writeValueAsString(foo);
       
        // views not used for deserialization
        Foo result = xmlMapper.readValue(xml, Foo.class);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.