Jackson datatype module for Javaslang library
<dependency>
<groupId>io.javaslang</groupId>
<artifactId>javaslang-jackson</artifactId>
<version>2.0.2</version>
</dependency>
compile("io.javaslang:javaslang-jackson:2.0.2")
Just register a new instance of JavaslangModule
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaslangModule());
String json = mapper.writer().writeValueAsString(List.of(List.of(1)));
// = [[1]]
Object restored1 = mapper.readValue(json, List.class);
// = List(java.util.ArrayList(1))
Object restored2 = mapper.readValue(json, new TypeReference<List<List<?>>>() {});
// = List(List(1))
Developer versions can be found here.
<dependency>
<groupId>io.javaslang</groupId>
<artifactId>javaslang-jackson</artifactId>
<version>2.1.0-SNAPSHOT</version>
</dependency>
Ensure that your ~/.m2/settings.xml
contains the following:
<profiles>
<profile>
<id>allow-snapshots</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
compile("io.javaslang:javaslang-jackson:2.1.0-SNAPSHOT")
Ensure that your build.gradle
contains the following:
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}