How can provide JsonFormats for case class that references itself ?
I'm following this guideline and wrote following code
case class Item(name: String, desc: Option[String], prices: Array[String], subitems: Option[List[Item]])
import spray.json._
import DefaultJsonProtocol._ // !!! IMPORTANT, else `convertTo` and `toJson` won't work
object MyJsonProtocol extends DefaultJsonProtocol {
implicit val menuItemFormat = jsonFormat(Item, "name", "desc", "prices", "subitems")
}
import MyJsonProtocol._
and I get following error message meaning of which I unfortunately don't understand.
could not find implicit value for evidence parameter of type Hi.MyJsonProtocol.JF[Option[List[mypkg.Item]]]
implicit val menuItemFormat = jsonFormat(Item, "name", "desc", "prices", "subitems")
^
How can I fix it ?