This is a jackson module that brings support for FunctionalJava data structures.
jackson-module-fj
is hosted on Artifactory OSS repository.
With gradle
, you can refer to jackson-module-fj
snapshot version in the following way:
repositories {
maven {
url 'https://oss.jfrog.org/artifactory/libs-snapshot/'
}
}
dependencies {
compile('com.novarto:jackson-module-fj:0.9-SNAPSHOT')
}
You can refer to jackson-module-fj
in Maven and other tools equivalently.
You just need to register the module in your object mapper:
mapper.registerModule(new FjModule());
Full example is available here.
If you're using immutable data structures, chances are you are also using immutable beans / data classes.
Therefore jackson-module-fj
automatically registers the parameter names module.
This way serialization / deserialization of immutable java classes works out of the box, without having to specify annotations, etc.
For parameter names module to work,
you need to retain parameter information in the produced bytecode. This happens via the -parameters
compiler flag.
In gradle this is achieved like this:
[compileJava, compileTestJava].each() {
it.options.compilerArgs += ["-parameters"]
}
Currently jackson-module-fj
supports the following fj
data types:
List
Option
Either
P1
P2
HashSet
HashMap
Tree
HashArrayMappedTrie
The list is likely to expand. If you require support for a new data structure, open an issue, or better yet - send us a PR.
- Extensive automated testing of serializer/deserializer implementations via property based testing