Scala Circe with generics
I am trying to use the scala json library Circe, wrapping it in a simple trait to provide conversion to/from json for which I have the following: import io.circe.generic.auto._ import io.circe.parser._ import io.circe.syntax._ trait JsonConverter { def toJson[T](t : T) : String def fromJson[T](s: String) : T } case class CirceJsonConverter() extends JsonConverter{ override def toJson[T](t: T): String = t.asJson.noSpaces override def fromJson[T](s: String): T = decode[T](s).getOrElse(null).asInstanceOf[T] } The aim of this is to simply be able to call JsonConverter with any object and have it