title: Implicit conversion of Scala Map
body: <p>I am building a custom json parser using an implicits design pattern in scala &gt; this is more an exercise to master the implicits system  ( i understand there are libraries that do Json parsing)</p>
  <p>I can get my json parser to serialize everything up to maps, but the compiler for whatever reason does not seem able to find my implicit JsonMap -&gt; basically I want to parse a string containing key value pairs, put it into a scala Map and then pass that into my custom JsonMap class. This approach works for regular arrays, but not Maps.</p>
  <p>The error returned is <code>No implicits found for parameter converter JsonValue[Map[String, Json]]</code></p>
  <p>My implicit converter is supposed to be the MapJsonValue of the JsonValue class -&gt; the apply method of the Json object takes the implicit converter. Can anyone see what I am doing wrong here?</p>
  <pre><code>package Json
  
  sealed trait Json
  
  object Json {
    case class JsonString( value: String) extends Json {
      override def toString: String = value
    }
    case class JsonNumber(value: Double) extends Json{
      override def toString: String = value.toString
    }
    case class JsonBoolean(value: Boolean) extends Json{
      override def toString: String = value.toString
    }
    case class JsonNull(value: Null) extends Json{
      override def toString: String = value
    }
    case class JsonList(items: Json*) extends Json
  
    case class JsonMap(items: Map[String,Json]) extends Json
  
    object JsonMap{
      def fromString(x: String): Json = {
        var map = x.stripPrefix(&quot;{&quot;).stripSuffix(&quot;}&quot;).  split(&quot;,&quot;).map(_.split(&quot;:&quot;)).map { case Array(k, v) =&gt; (k, Json.fromString(v) ) }.toMap
        map = Json(map)  Error: No implicits found for parameter converter JsonValue[Map[String, Json]]
      }
  
  
    }
  
    object JsonList {
      def fromString(x: String): Json = Json(x.stripPrefix(&quot;[&quot;).stripSuffix(&quot;]&quot;) .split(&quot;,&quot;).toSeq)
  
  
    }
  
    def apply[T](x:T)(implicit converter: JsonValue[T]): Json = converter.serialize(x)
  
    def fromString(x: String): Json = x match {
      case x if x.startsWith(&quot;[&quot;) =&gt; JsonList.fromString(x)
      case x if x.startsWith(&quot;{&quot;) =&gt; JsonMap.fromString(x)
      case &quot;null&quot; =&gt; new JsonNull(value = null)
      case &quot;True&quot; =&gt; new JsonBoolean(true)
      case &quot;False&quot;=&gt; new JsonBoolean(false)
      case _ =&gt; new JsonString(x)
    }
  
  
  
   }
  
  trait JsonValue[T] {
  
    def serialize(t: T): Json
  
  }
  
  object JsonValue{
    implicit object StringJsonValue extends JsonValue[String]{
      def serialize(t: String): Json.JsonString = Json.JsonString(t)
    }
    implicit object NumJsonValue extends JsonValue[Double]{
      def serialize(t: Double): Json.JsonNumber = Json.JsonNumber(t)
    }
    implicit object BooleanJsonValue extends JsonValue[Boolean]{
      def serialize(t: Boolean): Json.JsonBoolean = Json.JsonBoolean(t)
    }
  
    implicit object NullJsonValue extends JsonValue[Null]{
      def serialize(t: Null): Json.JsonNull = Json.JsonNull(t)
    }
  
  
  
    implicit def MapJsonValue[T: JsonValue]: JsonValue[Map[String, T]] = new JsonValue[Map[String, T]]{
      def serialize(t:  Map[String, T]):Json.JsonMap = {
        Json.JsonMap(t.map(t =&gt; t._1 -&gt; implicitly[JsonValue[T]].serialize(t._2) )    )
      }
    }
  
    implicit def SeqJsonValue[T: JsonValue]: JsonValue[Seq[T]] = new JsonValue[Seq[T]]{
      def serialize(t: Seq[T]):Json.JsonList = {
        Json.JsonList(t.map(implicitly[JsonValue[T]].serialize):_*)
      }
    }
  
  
  
  
  }
  
  
  
  </code></pre>