Package org.codehaus.jackson.map

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


  }

  @Test
  public void testDeserializeArray() throws JsonParseException, JsonMappingException, IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(STJSModule.getModule());
    Array<Integer> a = mapper.readValue("[1,2,3]",
        mapper.getTypeFactory().constructCollectionLikeType(Array.class, Integer.class));
    assertNotNull(a);
    assertEquals(3, a.$length());
    assertEquals(2, (int) a.$get(1));
View Full Code Here


  }

  @Test
  public void testDeserializeArrayChildren() throws JsonParseException, JsonMappingException, IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(STJSModule.getModule());
    Pojo2 p = mapper.readValue("{\"children\":[{\"n\":1}]}", Pojo2.class);
    assertNotNull(p);
    assertNotNull(p.getChildren());
    assertEquals(1, p.getChildren().$length());
    assertEquals(1, p.getChildren().$get(0).getN());
View Full Code Here

  }

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

    Map<String, Integer> m = mapper.readValue("{\"a\":1}",
        mapper.getTypeFactory().constructMapLikeType(Map.class, String.class, Integer.class));
    assertNotNull(m);
    assertEquals(1, (int) m.$get("a"));
View Full Code Here

  }

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

    Pojo3 p = mapper.readValue("{\"children\":{\"b\":{\"n\":1}}}", Pojo3.class);
    assertNotNull(p);
    assertNotNull(p.getChildren());
    assertNotNull(p.getChildren().$get("b"));
View Full Code Here

  }

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

    Date d = mapper.readValue("\"2011-11-09 17:10:00\"", Date.class);
    assertNotNull(d);
    assertEquals(10, (int) d.getMonth());
  }
View Full Code Here

//            new org.codehaus.jackson.smile.SmileFactory();
        ;
//        ((SmileFactory) jsonF).configure(SmileGenerator.Feature.CHECK_SHARED_NAMES, false);
           
        final ObjectMapper jsonMapper = new ObjectMapper(jsonF);
        jsonMapper.registerModule(new AfterburnerModule());

//      jsonMapper.configure(SerializationConfig.Feature.USE_STATIC_TYPING, true);

        /*
        final SmileFactory smileFactory = new SmileFactory();
View Full Code Here

        ObjectMapper mapperFast = new ObjectMapper(f);
       
        // !!! TEST -- to get profile info, comment out:
//        mapperSlow.registerModule(new AfterburnerModule());

        mapperFast.registerModule(new AfterburnerModule());
        new TestSerializePerf().testWith(mapperSlow, mapperFast);
    }

    private void testWith(ObjectMapper slowMapper, ObjectMapper fastMapper)
        throws IOException
View Full Code Here

//            new org.codehaus.jackson.smile.SmileFactory();
            new JsonFactory()
        ;
       
        final ObjectMapper jsonMapper = new ObjectMapper(jsonF);
        jsonMapper.registerModule(new com.fasterxml.jackson.module.afterburner.AfterburnerModule());

        byte[] json = jsonMapper.writeValueAsBytes(item);
        System.out.println("Warmed up: data size is "+json.length+" bytes; "+REPS+" reps -> "
                +((REPS * json.length) >> 10)+" kB per iteration");
        System.out.println();
View Full Code Here

        ObjectMapper mapperFast = new ObjectMapper(f);
       
        // !!! TEST -- to get profile info, comment out:
        mapperSlow.registerModule(new AfterburnerModule());

        mapperFast.registerModule(new AfterburnerModule());
        new TestDeserializePerf().testWith(mapperSlow, mapperFast);
    }

    private void testWith(ObjectMapper slowMapper, ObjectMapper fastMapper)
        throws IOException
View Full Code Here

    List<HttpMessageConverter<?>> converters = restTemplate.getMessageConverters();
    for (HttpMessageConverter<?> converter : converters) {
      if(converter instanceof MappingJacksonHttpMessageConverter) {
        MappingJacksonHttpMessageConverter jsonConverter = (MappingJacksonHttpMessageConverter) converter;
        ObjectMapper objectMapper = new ObjectMapper();       
        objectMapper.registerModule(new NetFlixModule());
        jsonConverter.setObjectMapper(objectMapper);
      }
    }
  }
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.