Package com.fasterxml.jackson.dataformat.xml

Examples of com.fasterxml.jackson.dataformat.xml.JacksonXmlModule


        DefaultList output = mapper.readValue(json, DefaultList.class);
        assertNotNull(output.value);
        assertEquals(2, output.value.length);

        // but can be changed not to use wrapping by default
        JacksonXmlModule module = new JacksonXmlModule();
        module.setDefaultUseWrapper(false);
        mapper = new XmlMapper(module);
        json = mapper.writeValueAsString(input);
        assertEquals("<DefaultList><value><v>a</v></value><value><v>b</v></value></DefaultList>", json);
        output = mapper.readValue(json, DefaultList.class);
        assertNotNull(output.value);
View Full Code Here


        DefaultList output = mapper.readValue(json, DefaultList.class);
        assertNotNull(output.value);
        assertEquals(1, output.value.length);

        // but without, should work as well
        JacksonXmlModule module = new JacksonXmlModule();
        module.setDefaultUseWrapper(false);
        mapper = new XmlMapper(module);
        json = "<DefaultList><value></value></DefaultList>";
        output = mapper.readValue(json, DefaultList.class);
        assertNotNull(output.value);
        assertEquals(1, output.value.length);
View Full Code Here

        _testListSerialization(false);
    }
       
    private void _testListSerialization(boolean useWrapping) throws Exception
    {
        JacksonXmlModule module = new JacksonXmlModule();
        module.setDefaultUseWrapper(useWrapping);
        XmlMapper xmlMapper = new XmlMapper(module);
        AnnotationIntrospector introspector = new JacksonAnnotationIntrospector();
        xmlMapper.setAnnotationIntrospector(introspector);

        SampleResource r1 = new SampleResource();
View Full Code Here

        _testArraySerialization(false);
    }
   
    private void _testArraySerialization(boolean useWrapping) throws Exception
    {
        JacksonXmlModule module = new JacksonXmlModule();
        module.setDefaultUseWrapper(useWrapping);
        XmlMapper xmlMapper = new XmlMapper(module);
        AnnotationIntrospector introspector = new JacksonAnnotationIntrospector();
        xmlMapper.setAnnotationIntrospector(introspector);

        SampleResource r1 = new SampleResource();
View Full Code Here

            MAPPER.readValue(XML, JAXBStyle.class);
            fail("Should have failed");
        } catch (JsonProcessingException e) {
            verifyException(e, "Unrecognized");
        }
        JacksonXmlModule module = new JacksonXmlModule();
        module.setXMLTextElementName("value");
        XmlMapper mapper = new XmlMapper(module);
        JAXBStyle pojo = mapper.readValue(XML, JAXBStyle.class);
        assertEquals("foo", pojo.value);
    }
View Full Code Here

    }

    // [Issue#66], implicit property from "XmlText"
    public void testIssue66() throws Exception
    {
        JacksonXmlModule module = new JacksonXmlModule();
        module.setDefaultUseWrapper(false);
        XmlMapper mapper = new XmlMapper(module);
        final String XML = "<Issue66Bean id=\"id\">text</Issue66Bean>";

        // let's start with deserialization
        Issue66Bean node = mapper.readValue(XML, Issue66Bean.class);
View Full Code Here

    }
   
    // for [Issue#41]
    public void testCustomSerializer() throws Exception
    {
        JacksonXmlModule module = new JacksonXmlModule();
        module.addSerializer(String.class, new CustomSerializer());
        XmlMapper xml = new XmlMapper(module);
        assertEquals("<String>custom:foo</String>", xml.writeValueAsString("foo"));
    }
View Full Code Here

        // /////////////////////////////////////////////////////////////////////
        String response = ninjaTestBrowser.makeXmlRequest(getServerAddress()
                + "api/bob@gmail.com/articles.xml");
        System.out.println("response xml: " + response);
       
        JacksonXmlModule module = new JacksonXmlModule();
        // and then configure, for example:
        module.setDefaultUseWrapper(false);
        XmlMapper xmlMapper = new XmlMapper(module);
       

        ArticlesDto articlesDto = xmlMapper.readValue(response, ArticlesDto.class);
View Full Code Here

        // /////////////////////////////////////////////////////////////////////
        String response = ninjaTestBrowser.makeXmlRequest(getServerAddress()
                + "api/bob@gmail.com/articles.xml");
        System.out.println("response xml: " + response);
       
        JacksonXmlModule module = new JacksonXmlModule();
        // and then configure, for example:
        module.setDefaultUseWrapper(false);
        XmlMapper xmlMapper = new XmlMapper(module);
       

        ArticlesDto articlesDto = xmlMapper.readValue(response, ArticlesDto.class);
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.dataformat.xml.JacksonXmlModule

Copyright © 2018 www.massapicom. 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.