Package org.codehaus.jackson.map

Examples of org.codehaus.jackson.map.ObjectMapper.registerModule()


                        }
                        else
                        {
                            final Map<String, Object> attributes = configuredObject.getAttributes();
                            final ObjectMapper objectMapper = new ObjectMapper();
                            objectMapper.registerModule(_module);
                            byte[] attributesAsBytes = objectMapper.writeValueAsBytes(attributes);

                            ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes);
                            insertStmt.setBinaryStream(3, bis, attributesAsBytes.length);
                        }
View Full Code Here


            stmt.setString(1, configuredObject.getId().toString());
            ResultSet rs = stmt.executeQuery();
            try
            {
                final ObjectMapper objectMapper = new ObjectMapper();
                objectMapper.registerModule(_module);
                if (rs.next())
                {
                    PreparedStatement stmt2 = conn.prepareStatement(UPDATE_CONFIGURED_OBJECTS);
                    try
                    {
View Full Code Here

        module.addDeserializer(District.class, new DistrictDeserializer());
        module.addDeserializer(School.class, new SchoolDeserializer());
        module.addDeserializer(Teacher.class, new TeacherDeserializer());
        module.addDeserializer(Student.class, new StudentDeserializer());

        mapper.registerModule(module);

        T parsedResponse = parseJson(mapper, httpResponse);

        EntityUtils.consume(httpResponse.getEntity());
View Full Code Here

public class JacksonTest {
  @Test
  public void testSerializeArray() throws JsonGenerationException, JsonMappingException, IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(STJSModule.getModule());

    String s = mapper.writeValueAsString(JSCollections.$array(1, 2, 3));
    assertEquals("[1,2,3]", s);
  }
View Full Code Here

  }

  @Test
  public void testSerializeArrayPojo() throws JsonGenerationException, JsonMappingException, IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(STJSModule.getModule());

    String s = mapper.writeValueAsString(JSCollections.$array(new Pojo(1), new Pojo(2)));
    assertEquals("[{\"n\":1},{\"n\":2}]", s);
  }
View Full Code Here

  }

  @Test
  public void testSerializeArrayPojoChildren() throws JsonGenerationException, JsonMappingException, IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(STJSModule.getModule());

    Pojo2 p = new Pojo2();
    p.setChildren(JSCollections.$array(new Pojo(1)));
    String s = mapper.writeValueAsString(p);
    assertEquals("{\"children\":[{\"n\":1}]}", s);
View Full Code Here

  }

  @Test
  public void testSerializeMap() throws JsonGenerationException, JsonMappingException, IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(STJSModule.getModule());

    String s = mapper.writeValueAsString(JSCollections.$map("a", 1));
    assertEquals("{\"a\":1}", s);
  }
View Full Code Here

  }

  @Test
  public void testSerializeMapPojo() throws JsonGenerationException, JsonMappingException, IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(STJSModule.getModule());

    String s = mapper.writeValueAsString(JSCollections.$map("A", new Pojo(1)));
    assertEquals("{\"A\":{\"n\":1}}", s);
  }
View Full Code Here

  }

  @Test
  public void testSerializeMapPojoChildren() throws JsonGenerationException, JsonMappingException, IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(STJSModule.getModule());

    Pojo3 p = new Pojo3();
    p.setChildren(JSCollections.$map("b", new Pojo(1)));
    String s = mapper.writeValueAsString(p);
    assertEquals("{\"children\":{\"b\":{\"n\":1}}}", s);
View Full Code Here

  }

  @Test
  public void testSerializeDate() throws JsonGenerationException, JsonMappingException, IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(STJSModule.getModule());

    String s = mapper.writeValueAsString(new Date(2011, 10, 9, 17, 10, 0, 0));
    assertEquals("\"2011-11-09 17:10:00\"", s);
  }
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.