Jsoniter Scala

structible-jsoniter-scala is available for Scala 2.12 and 2.13.

It provides derivations for JsonCodec instances.

Dependency

sbt
libraryDependencies += "com.github.cerst" % "structible-jsoniter-scala" % "0.3.0"
Maven
<dependency>
  <groupId>com.github.cerst</groupId>
  <artifactId>structible-jsoniter-scala</artifactId>
  <version>0.3.0</version>
</dependency>
Gradle
dependencies {
  compile group: 'com.github.cerst', name: 'structible-jsoniter-scala', version: '0.3.0'
}

Example

import com.github.cerst.structible.core.Structible
import com.github.cerst.structible.jsoniterscala.ops._
import com.github.plokhotnyuk.jsoniter_scala.core._
import com.github.plokhotnyuk.jsoniter_scala.macros._

object JsonCodecExample {

  final case class PersonId(value: Long) {
    require(value >= 0, s"PersonId must be non-negative (got: '$value')")
  }

  object PersonId {

    private val structible: Structible[Long, PersonId] = Structible.instanceUnsafe(PersonId.apply, _.value)

    implicit val jsonCodecForPersonId: JsonCodec[PersonId] = structible.toJsonCodec

  }

  final case class Person(personId: PersonId)

  object Person {

    implicit val jsonCodecForPerson: JsonValueCodec[Person] = JsonCodecMaker.make(CodecMakerConfig())

  }

}
The source code for this page can be found here.