Jackson Module: Guava

Guava module for Jackson aims to provide full support for Google Guava (formerly known as "Google Collections") package, and specifically its Collection types.

Project home page is at GitHub, jackson-datatype-guava.

As of October 2011 project is still more of a protype, but it does support subset of Guava collection types; most notably deserializers for immutable types and hash multisets.

Usage

Register module with ObjectMapper:

    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new GuavaModule());

And then you can read and write (some of) Guava datatypes like so:

    ImmutableList<Integer> list = mapper.readValue("[1,2,3]",
        new TypeReference<ImmutableList<Integer>>() { });
    String json = mapper.writeValue(list); // output as String


Back to JacksonModuleProjects.


CategoryJackson

JacksonModuleGuava (last edited 2011-10-30 17:24:53 by TatuSaloranta)

Copyright ©2009 FasterXML, LLC