title: Scala Reads: How to handle Option[Map[String, Any]]
body: <p>I cannot wrap my head around why it throws an error on the following line:</p>
  
  <pre><code>val anyReads = Reads[Any](m =&gt; metaValueToJsValue(m))
  </code></pre>
  
  <p>Error Message:  <code>type mismatch; found : play.api.libs.json.JsValue required: play.api.libs.json.JsResult[Any] Note: implicit value readsMap is not applicable here because it comes after the application point and it lacks an explicit result type</code></p>
  
  <p>I've pasted my code below.
  Any help is appreciated! Thanks!</p>
  
  <pre><code>import play.api.libs.json._
  import play.api.libs.json.util._
  import play.api.libs.functional.syntax._
  
  case class TempClass(
    metaValue: Option[Map[String, Any]])
  
  object TempClass {
  
    val anyReads = Reads[Any](m =&gt; metaValueToJsValue(m))
  
    def metaValueToJsValue(m: Any): JsValue = {
      m match {
        case s: String =&gt; JsString(s)
        case n: Int =&gt; JsNumber(n): JsValue
        case n: Long =&gt; JsNumber(n): JsValue
        case n: Double =&gt; JsNumber(n): JsValue
        case n: BigDecimal =&gt; JsNumber(n): JsValue
        case b: Boolean =&gt; JsBoolean(b)
        case l: Seq[Any] =&gt; JsArray(l.map(metaValueToJsValue)): JsValue
      }
    }
  
    implicit val readsMap = Reads[Map[String, Any]](m =&gt; Reads.mapReads[Any](anyReads).reads(m))
    implicit val reads = Json.reads[TempClass]
  }
  </code></pre>