Search in sources :

Example 31 with XmlMapper

use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project tutorials by eugenp.

the class SimpleBeanForCapitalizedFields method whenJavaGotFromXmlStrWithCapitalElem_thenCorrect.

@Test
public void whenJavaGotFromXmlStrWithCapitalElem_thenCorrect() throws IOException {
    XmlMapper xmlMapper = new XmlMapper();
    SimpleBeanForCapitalizedFields value = xmlMapper.readValue("<SimpleBeanForCapitalizedFields><X>1</X><y>2</y></SimpleBeanForCapitalizedFields>", SimpleBeanForCapitalizedFields.class);
    assertTrue(value.getX() == 1 && value.getY() == 2);
}
Also used : XmlMapper(com.fasterxml.jackson.dataformat.xml.XmlMapper) Test(org.junit.Test)

Example 32 with XmlMapper

use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project tutorials by eugenp.

the class SimpleBeanForCapitalizedFields method whenJavaGotFromXmlStr_thenCorrect.

@Test
public void whenJavaGotFromXmlStr_thenCorrect() throws IOException {
    XmlMapper xmlMapper = new XmlMapper();
    SimpleBean value = xmlMapper.readValue("<SimpleBean><x>1</x><y>2</y></SimpleBean>", SimpleBean.class);
    assertTrue(value.getX() == 1 && value.getY() == 2);
}
Also used : XmlMapper(com.fasterxml.jackson.dataformat.xml.XmlMapper) Test(org.junit.Test)

Example 33 with XmlMapper

use of com.fasterxml.jackson.dataformat.xml.XmlMapper in project ihmc-pub-sub by ihmcrobotics.

the class XMLSerializer method createXMLObjectMapper.

private static ObjectMapper createXMLObjectMapper() {
    JacksonXmlModule module = new JacksonXmlModule();
    module.setDefaultUseWrapper(false);
    XmlMapper objectMapper = new XmlMapper(module);
    objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
    return objectMapper;
}
Also used : JacksonXmlModule(com.fasterxml.jackson.dataformat.xml.JacksonXmlModule) XmlMapper(com.fasterxml.jackson.dataformat.xml.XmlMapper)

Aggregations

XmlMapper (com.fasterxml.jackson.dataformat.xml.XmlMapper)33 Test (org.junit.Test)15 IOException (java.io.IOException)8 JacksonXmlModule (com.fasterxml.jackson.dataformat.xml.JacksonXmlModule)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 InputStream (java.io.InputStream)5 BadRequestException (ninja.exceptions.BadRequestException)5 File (java.io.File)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 JsonParser (com.fasterxml.jackson.core.JsonParser)2 DeserializationContext (com.fasterxml.jackson.databind.DeserializationContext)2 DeserializationProblemHandler (com.fasterxml.jackson.databind.deser.DeserializationProblemHandler)2 AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)2 HashMap (java.util.HashMap)2 NinjaTest (ninja.NinjaTest)2 JsonInclude (com.fasterxml.jackson.annotation.JsonInclude)1 JsonPointer (com.fasterxml.jackson.core.JsonPointer)1 AnnotationIntrospector (com.fasterxml.jackson.databind.AnnotationIntrospector)1 DeserializationFeature (com.fasterxml.jackson.databind.DeserializationFeature)1