Shapeless JsonFormats for spray-json
Latest commit 77a49a3 Jan 1, 2017 @fommil committed on GitHub Drone 0.5 (#32)
* upgrade CI

* fixup! upgrade CI


Automatically derive spray-json JsonFormats, powered by shapeless (no macros were written during the creation of this library).

For documentation, read the scaladocs and for examples read the test cases.

Please read the documentation - especially the caveats - and examples before raising a ticket.


// always check maven central for the lastest release
libraryDependencies += "com.github.fommil" %% "spray-json-shapeless" % "1.3.0"
import spray.json._
import fommil.sjs.FamilyFormats._

object domain {
  sealed trait SimpleTrait
  case class Foo(s: String) extends SimpleTrait
  case class Bar() extends SimpleTrait
  case object Baz extends SimpleTrait
  case class Faz(o: Option[String]) extends SimpleTrait
object use {
  import domain._

  Foo("foo").toJson                // """{"s":"foo"}"""
  Faz(Some("meh")).toJson          // """{"o":"meh"}"""
  Faz(None).toJson                 // """{}"""
  (Foo("foo"): SimpleTrait).toJson // """{"type":"Foo","s":"foo"}"""
  (Bar(): SimpleTrait).toJson      // """{"type":"Bar"}"""
  (Baz: SimpleTrait).toJson        // """{"type":"Baz"}"""
  (Faz(None): SimpleTrait).toJson  // """{"type":"Faz"}"""


spray-json-shapeless is Free Software under the Apache License v2.

I would prefer a copyleft license because TypeSafe have set the precedent of closing sources and it is extremely concerning that this is happening within our community.

However, both of the primary upstream projects, spray-json and shapeless, are published under Apache v2, so it is more appropriate to publish this project on the same terms.