title: Scala Circe with generics
body: <p>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:</p>
  
  <pre><code>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]
  }
  </code></pre>
  
  <p>The aim of this is to simply be able to call JsonConverter with any object and have it convert it to/from json as such <code>jsonConverter.toJson(0) must equalTo("0")</code> , however when I try to compile it I get the following:</p>
  
  <pre><code>[error] could not find implicit value for parameter encoder: io.circe.Encoder[T]
  [error]   override def toJson[T](t: T): String = t.asJson.noSpaces
  [error]                                            ^
  [error] could not find implicit value for parameter decoder: io.circe.Decoder[T]
  [error]   override def fromJson[T](s: String): T = decode[T](s).getOrElse(null).asInstanceOf[T]
  [error]                                                     ^
  [error] two errors found
  </code></pre>
  
  <p>I can of course have a class that everything I intend to put through the converter inherit from, but I had the impression that circe could auto generate the encoders/decoders?</p>