Package com.fasterxml.jackson.dataformat.xml

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


        }

        // and then try reading back
        JavaType resListType = xmlMapper.getTypeFactory()
                .constructCollectionType(List.class, SampleResource.class);
        Object ob = xmlMapper.reader(resListType).readValue(xml);
        assertNotNull(ob);

//      System.err.println("XML -> "+xmlMapper.writerWithDefaultPrettyPrinter().writeValueAsString(ob));
       
        assertTrue(ob instanceof List);
View Full Code Here


        if (xml.indexOf("<SampleResources>") < 0) {
            fail("Unexpected output: should have <SampleResources> as root element, got: "+xml);
        }

        // and then try reading back
        SampleResource[] result = xmlMapper.reader(SampleResource[].class).readValue(xml);
        assertNotNull(result);

//      System.err.println("XML -> "+xmlMapper.writerWithDefaultPrettyPrinter().writeValueAsString(ob));
       
        assertEquals(2, result.length);
View Full Code Here

        ObjectMapper mapper = new ObjectMapper();
        XmlMapper xmlMapper = new XmlMapper();

        ObjectReader detecting = mapper.reader(POJO.class);
        detecting = detecting
                .withFormatDetection(detecting, xmlMapper.reader(POJO.class));
        POJO pojo = detecting.readValue(utf8Bytes("<POJO><y>3</y><x>1</x></POJO>"));
        assertNotNull(pojo);
        assertEquals(1, pojo.x);
        assertEquals(3, pojo.y);
    }
View Full Code Here

        list.v.add(new POJO(3, 4));
        String xml = xmlMapper.writeValueAsString(list);

        ObjectReader detecting = mapper.reader(ListPOJO.class);
        ListPOJO resultList = detecting
                .withFormatDetection(detecting, xmlMapper.reader(ListPOJO.class))
                .readValue(utf8Bytes(xml));
        assertNotNull(resultList);
        assertEquals(2, resultList.v.size());
    }
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.