/jackson-module-fj

A Jackson module for FunctionalJava data structures

Primary LanguageJavaApache License 2.0Apache-2.0

jackson-module-fj

This is a jackson module that brings support for FunctionalJava data structures.

Usage

jackson-module-fj is hosted on Artifactory OSS repository.

Download

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.

Refer from your code

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.

Compiler settings

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"]
}

Features

Supported data structures

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.

Miscellaneous