Giter Site home page Giter Site logo

crumbpicker / jackson-module-scala Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fasterxml/jackson-module-scala

0.0 2.0 0.0 17.01 MB

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

Home Page: http://wiki.fasterxml.com/JacksonModuleScala

Ruby 0.05% Scala 98.75% Java 1.19%

jackson-module-scala's Introduction

Build Status

IMPORTANT

Version 2.6.0 of this module has been released incorrectly. Please refrain from using this version. A patch release, 2.6.0-1, has been made available instead.

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] (http://paranamer.codehaus.org/), 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

jackson-module-scala's People

Contributors

aarondav avatar arnauld avatar casualjim avatar christophercurrie avatar cowtowncoder avatar daveclay avatar devth avatar dieu avatar dpratt avatar hvesalai avatar kscaldef avatar ming13 avatar nbauernfeind avatar noam-almog avatar orac avatar prb avatar relaxkeren avatar rintcius avatar scarytom avatar umcodemonkey avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.