FasterXML/jackson-module-scala


Add-on module for Jackson (http://wiki.fasterxml.com/JacksonHome) to support Scala-specific datatypes

http://wiki.fasterxml.com/JacksonModuleScala

Language: Scala


Build Status Maven Central

IMPORTANT

Please use at least versions 2.6.5, or 2.7.2; earlier released versions are known to contain significant bugs.

Overview

Jackson is a fast JSON processor for Java that supports three models: streaming, node, and object mapping (akin to the three independent models SAX, DOM, and JAXB in XML).

The object mapping model is a high-level processing model that allows the user to project JSON data onto a domain-specific data model appropriate for their application, without having to deal with the low-level mechanics of JSON parsing. It is the standard object mapping parser implementaton in Jersey, the reference implementation for JSR-311 (Java API for Restful Web Services).

Scala is a functional programming language for the JVM that supports Java interoperability. Its standard library is quite distinct from Java, and does not fulfill the expectations of Jacksons default mappings. Notably, Scala collections do not derive from java.util.Collection or its subclasses, and Scala properties do not (by default) look like Java Bean properties.

The Scala Module supports serialization and limited deserialization of Scala Case Classes, Sequences, Maps, Tuples, Options, and Enumerations.

Caveats

Support for class constructor arguments currently depends upon Paranamer, specifically an implementation that depends upon constructor parameter names being present in the class debug information. Since this is the default in Scala, it is usually not an issue, but since it's possible to turn this off, be aware that the current version will throw an exception if it cannot find the constructor parameter names. Future versions may permit configuration to suppress this exception.

Usage

To use the Scala Module in Jackson, simply register it with the ObjectMapper instance:

val mapper = new ObjectMapper()
mapper.registerModule(DefaultScalaModule)

DefaultScalaModule is a Scala object that includes support for all currently supported Scala data types. If only partial support is desired, the component traits can be included individually:

val module = new OptionModule with TupleModule {}
val mapper = new ObjectMapper()
mapper.registerModule(module)

You can also mixin ScalaObjectMapper (experimental) to get rich wrappers that automatically convert scala manifests directly into TypeReferences for Jackson to use:

val mapper = new ObjectMapper() with ScalaObjectMapper
mapper.registerModule(DefaultScalaModule)
val myMap = mapper.readValue[Map[String,Tuple2[Int,Int]]](src)

Consult the Scaladoc for further details.

Building

The master branch often depends on SNAPSHOT versions of the core Jackson projects, which are published to the Sonatype OSS Repository. To make these dependencies available, create a file called sonatype.sbt in the same directory as build.sbt with the following content. The project .gitignore file intentionally prevents this file from being checked in.

resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

Download, docs

Check out Wiki. API Scaladocs can be found on the project site but they are not really well suited to end users, as most classes are implementation details of the module.

Acknowledgements

Developed with IntelliJ IDEA

Project Statistics

Sourcerank 17
Repository Size 15.3 MB
Stars 385
Forks 108
Watchers 28
Open issues 88
Dependencies 0
Contributors 42
Tags 89
Created
Last updated
Last pushed

Top Contributors See all

Christopher Currie Nate Bauernfeind Morten Kjetland Tatu Saloranta theif daveclay PJ Fanning sullis David Pratt brharrington Christopher Currie Ismael Juma Stefan Endrullis kenji yoshida Kevin Scaldeferri Anton Panasenko Seth Tisue Arnauld Loyer Ian Forsey Rintcius Blok

Packages Referencing this Repo

com.fasterxml.jackson.module:jackson-module-scala_2.13.0-M5
jackson-module-scala
Latest release 2.9.8 - Published - 385 stars
com.fasterxml.jackson.module:jackson-module-scala_2.13.0-M4
jackson-module-scala
Latest release 2.9.7 - Updated - 385 stars
org.skinny-framework.com.fasterxml.jackson.module:jackson-module-scala_2.12
jackson-module-scala
Latest release 2.8.4 - Published - 385 stars
org.skinny-framework.com.fasterxml.jackson.module:jackson-module-scala_2.10
jackson-module-scala
Latest release 2.8.4 - Published - 385 stars
com.fasterxml.jackson.module:jackson-module-scala_2.12.0-RC1
jackson-module-scala
Latest release 2.8.3 - Updated - 385 stars
com.fasterxml:jackson-module-scala
Add-on module for Jackson (http://jackson.codehaus.org) to support Scala (http://www.scala-la...
Latest release 1.9.3 - Updated - 385 stars
com.fasterxml.jackson.module:jackson-module-scala_2.11
jackson-module-scala
Latest release 2.9.9 - Updated - 385 stars
com.fasterxml.jackson.module:jackson-module-scala_2.10
jackson-module-scala
This package is no longer available on Maven
com.fasterxml.jackson.module:jackson-module-scala_2.9.1
jackson-module-scala
Latest release 2.3.5 - Updated - 385 stars
com.fasterxml.jackson.module:jackson-module-scala
Add-on module for Jackson (http://jackson.codehaus.org) to support Scala (http://www.scala-la...
Latest release 2.1.2 - Updated - 385 stars
com.fasterxml.jackson.module:jackson-module-scala_2.9.3
jackson-module-scala
Latest release 2.3.5 - Updated - 385 stars
com.fasterxml.jackson.module:jackson-module-scala_2.9.2
jackson-module-scala
Latest release 2.3.5 - Updated - 385 stars
com.fasterxml.jackson.module:jackson-module-scala_2.12
jackson-module-scala
Latest release 2.9.8 - Updated - 385 stars

Recent Tags See all

jackson-module-scala-2.9.9-for-scala-2.13.0-rc3 May 31, 2019
jackson-module-scala-2.9.9 May 19, 2019
jackson-module-scala-2.9.8-for-scala-2.13.0-rc1 April 06, 2019
jackson-module-scala-2.9.8 December 16, 2018
jackson-module-scala-2.9.7 September 22, 2018
jackson-module-scala-2.9.6 June 14, 2018
jackson-module-scala-2.9.5 March 28, 2018
jackson-module-scala-2.8.11 January 28, 2018
jackson-module-scala-2.9.4 January 28, 2018
jackson-module-scala-2.9.2 November 12, 2017
jackson-module-scala-2.8.10 September 11, 2017
jackson-module-scala-2.9.1 September 11, 2017
jackson-module-scala-2.9.0 July 30, 2017
jackson-module-scala-2.8.9 June 12, 2017
jackson-module-scala-2.9.0.pr3 April 25, 2017

Something wrong with this page? Make a suggestion

Last synced: 2019-06-10 15:54:45 UTC

Login to resync this repository