Scala/Scala.js JSON library, no thrills included
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
jello improve enum name handling for enum formatter May 7, 2018
project properly publish lib to maven Jan 1, 2019
.gitignore barebone Dec 29, 2015
.travis.yml
LICENSE Initial commit Dec 29, 2015
README.md travis Apr 3, 2018
build.sbt properly publish lib to maven Jan 1, 2019

README.md

jello

Build Status Scala.js Maven Central

http://search.maven.org/#artifactdetails|com.uniformlyrandom|jello_2.11|0.3.0|jar

Scala.js & JVM JSON marshalling library with straightforward format.

Why did I create yet another JSON library?

Scala.js prohibits dynamically invoked code, so one has to use macros where one would otherwise use mechanisms such as reflection etc.

At the same time, the Scala.js community created some idiomatic marshaling/pickling libraries which were a divergence from the common. (Play Framework etc..) As it turned out, if one wants to use one of these generic libraries on the back-end he could not use any of the existing Scala-js compatible JSON libraries.

Thus Jello was born.

Usage

Installation

libraryDependencies ++= Seq("com.uniformlyrandom" %%% "jello" % "0.3.0)

Overview

Jello takes inspiration from Play Json, the formatters need to be provided implicitly, it's recommended to have the companion object contain these formatters

case class A (
    m1: String,
    m2: Int
)

object A {
    implicit fmt: JelloFormat[A] = JelloFormat.format[A]
}

object App {

    import com.uniformlyrandom.jello.TypesLibrary._

    def main(args: Array[String]): Unit = {
        val a: A = A("value",1)
        val aJV: JelloValue = JelloJson.toJson(a)
        val aJson: String = JelloJson.toJsonString(aJV)
        //aJson == {"m1":"value","m2":1}
        val ajJV: JelloValue = JelloJson.parse(aJson)
        val aTry: Try[A] = JelloJson.fromJson(ajJV)
        
        assert(Try(a) == aTry)
    }
}

Supported features

  • Enumerations support
  • helper constructs to serialize traits