Giter VIP home page Giter VIP logo

jackson-datatype-joda's Introduction

Jackson module (jar) to support JSON serialization and deserialization of Joda data types.

Status

Build Status Maven Central Javadoc

Module has been production-ready since version 2.0, and offers relatively extensive support for Joda datatypes. Contributions are always welcome -- not all types are yet supported; and we may want to support even wider alternative formats on input side.

License

Apache License 2.0

Usage

Since this module extends basic Jackson databind functionality, you may want to check out documentation at Jackson-docs first.

Maven dependency

To use module on Maven-based projects, use following dependency:

<dependency>
  <groupId>com.fasterxml.jackson.datatype</groupId>
  <artifactId>jackson-datatype-joda</artifactId>
  <version>2.9.0</version>
</dependency>    

(or whatever version is most up-to-date at the moment)

Registering module

To use Joda datatypes with Jackson, you will first need to register the module first (same as with all Jackson datatype modules):

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

Reading and Writing Joda types

After registering Joda module, Jackson Databind will be able to write values of supported Joda types as JSON (and other formats Jackson supports), and read Joda values from same formats.

With JSON, for example, following would work

public class Bean {
  public DateTime start;
}

final String INPUT_JSON = "{\"start\" : \"1972-12-28T12:00:01.000Z\"}";
Bean bean = mapper.readValue(INPUT_JSON, Bean.class);

and property start of Bean would have expected DateTime value.

Conversely, you can produce JSON (and other supported formats) simply with:

String json = mapper.writeValueAsString(bean);
Assert.assertEquals(INPUT_JSON, json);

More

See Wiki for more information (javadocs, downloads).

jackson-datatype-joda's People

Contributors

arturdryomov avatar beamerblvd avatar chanjarster avatar clamothe avatar cowtowncoder avatar cstivers78 avatar deiga avatar dlvenable avatar ebourg avatar ginkel avatar hgschmie avatar jkolobok avatar joschi avatar joxertmd avatar kyje avatar lorcan avatar mveitas avatar ncjones avatar nezda avatar prb avatar rgilles avatar sbtourist avatar tatu-at-salesforce avatar valery1707 avatar ziobermichal avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.