- Notifications
You must be signed in to change notification settings - Fork82
Extension module to properly support full datatype set of Joda datetime library
License
FasterXML/jackson-datatype-joda
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Jackson datatype module (jar)to support JSON serialization (writing JSON) and deserialization (reading from JSON)ofJoda data types, such asDateTime.
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 alternativeformats on input side.
Since this module extends basicJackson databind functionality, you may want to check outdocumentation atJackson-docs first.
To use module on Maven-based projects, use following dependency:
<dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-joda</artifactId> <version>3.0.0-SNAPSHOT</version></dependency>
(or whatever version is most up-to-date at the moment)
To use Joda datatypes with Jackson, you will first need to register the module first (same aswith all Jackson datatype modules):
ObjectMappermapper =JsonMapper.builder().addModule(newJodaModule()).build();
Using older style (that is being phased out):
ObjectMappermapper =newObjectMapper();mapper.registerModule(newJodaModule());
After registering Joda module,Jackson Databind will be able to write valuesof supported Joda types as JSON (and other formats Jackson supports), and read Joda valuesfrom same formats.
With JSON, for example, following would work
publicclassBean {publicDateTimestart;}finalStringINPUT_JSON ="{\"start\" :\"1972-12-28T12:00:01.000Z\"}";Beanbean =mapper.readValue(INPUT_JSON,Bean.class);
and propertystart of Bean would have expectedDateTime value.
Conversely, you can produce JSON (and other supported formats) simply with:
Stringjson =mapper.writeValueAsString(bean);Assert.assertEquals(INPUT_JSON,json);
Module works with Joda version 2.10 (as of Jackson 3.0) and higher (CI tests compatibility since module version 2.14), even if it declares dependency to a newer version.This means that it is possible to use with older version by using Maven dependency override.
SeeWiki for more information (javadocs, downloads).
About
Extension module to properly support full datatype set of Joda datetime library
Resources
License
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.