Search in sources :

Example 11 with AfterburnerModule

use of com.fasterxml.jackson.module.afterburner.AfterburnerModule in project jackson-module-afterburner by FasterXML.

the class TestDeserializePerf method main.

public static void main(String[] args) throws Exception {
    //        JsonFactory f = new org.codehaus.jackson.smile.SmileFactory();
    JsonFactory f = new JsonFactory();
    ObjectMapper mapperSlow = new ObjectMapper(f);
    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);
}
Also used : AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) JsonFactory(com.fasterxml.jackson.core.JsonFactory) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 12 with AfterburnerModule

use of com.fasterxml.jackson.module.afterburner.AfterburnerModule in project jackson-module-afterburner by FasterXML.

the class VLTBet method testIssue.

public void testIssue() throws Exception {
    // create this ridiculously complicated object
    ItemData data = new ItemData();
    data.denomination = 100;
    Item item = new Item();
    item.data = data;
    item.productId = 123;
    List<Item> itemList = new ArrayList<Item>();
    itemList.add(item);
    PlaceOrderRequest order = new PlaceOrderRequest();
    order.orderId = 68723496;
    order.userId = "123489043";
    order.amount = 250;
    order.status = "placed";
    order.items = itemList;
    final Date now = new Date(999999L);
    order.createdAt = now;
    order.updatedAt = now;
    ObjectMapper vanillaMapper = new ObjectMapper();
    ObjectMapper abMapper = new ObjectMapper();
    abMapper.registerModule(new AfterburnerModule());
    // First: ensure that serialization produces identical output
    String origJson = vanillaMapper.writerWithDefaultPrettyPrinter().writeValueAsString(order);
    String abJson = abMapper.writerWithDefaultPrettyPrinter().writeValueAsString(order);
    assertEquals(origJson, abJson);
    // Then read the string and turn it back into an object
    // this will cause an exception unless the AfterburnerModule is commented out
    order = abMapper.readValue(abJson, PlaceOrderRequest.class);
    assertNotNull(order);
    assertEquals(250, order.amount);
}
Also used : AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)12 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)9 JsonFactory (com.fasterxml.jackson.core.JsonFactory)3 MediaContent (data.media.MediaContent)3 SerFeatures (serializers.SerFeatures)3 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)1 CBORFactory (com.fasterxml.jackson.dataformat.cbor.CBORFactory)1 SmileFactory (com.fasterxml.jackson.dataformat.smile.SmileFactory)1 JacksonXmlModule (com.fasterxml.jackson.dataformat.xml.JacksonXmlModule)1 XmlMapper (com.fasterxml.jackson.dataformat.xml.XmlMapper)1 GuavaModule (com.fasterxml.jackson.datatype.guava.GuavaModule)1 Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)1 JodaModule (com.fasterxml.jackson.datatype.joda.JodaModule)1 JavaTimeModule (com.fasterxml.jackson.datatype.jsr310.JavaTimeModule)1 ParameterNamesModule (com.fasterxml.jackson.module.paramnames.ParameterNamesModule)1 Stopwatch (com.google.common.base.Stopwatch)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 SchemaPath (org.apache.drill.common.expression.SchemaPath)1 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)1 Path (org.apache.hadoop.fs.Path)1