bizzabo / play-json-extensions

+22 field case class formatter and more for play-json
http://cvogt.org/play-json-extensions/api/
Other
196 stars 44 forks source link

could not find implicit value for parameter helper: ai.x.play.json.OptionValidationDispatcher[Option[Seq[com.company.project.JsonFormats.Test]]] #88

Open wkurkian opened 3 years ago

wkurkian commented 3 years ago

It seems like Option[Seq[T]] isn't handled by Jsonx.formatCaseClass.

Here is code I used to reproduce it:

import ai.x.play.json.implicits.optionWithNull
case class Test(value: String, and: Option[Seq[Test]])
implicit val testFormats = Jsonx.formatCaseClass[Test]

Here is the full error message:

could not find implicit value for parameter helper: play.api.libs.json.Reads[Option[Seq[com.company.project.JsonFormats.Test]]]
TRIGGERED BY: could not find implicit value for parameter helper: ai.x.play.json.OptionValidationDispatcher[Option[Seq[com.company.project.JsonFormats.Test]]]
TO SOLVE THIS
1. Make sure there is a Reads[Option[Seq[com.company.project.JsonFormats.Test]]] or Format[Option[Seq[com.company.project.JsonFormats.Test]]] in the implicit scope
2. In case of Reads[Option[...]] you need to either
   import ai.x.play.json.implicits.optionWithNull // suggested
   or
   import ai.x.play.json.implicits.optionNoError // buggy play-json 2.3 behavior
3. In case of Reads[... .type]
   import ai.x.play.json.SingletonEncoder.simpleName
   import ai.x.play.json.implicits.formatSingleton

  implicit val testFormats = Jsonx.formatCaseClass[Test]

Is there some workaround to tell formatCaseClass how to handle this case?

caente commented 3 years ago

this is possibly related to https://github.com/xdotai/play-json-extensions/issues/58

wkurkian commented 3 years ago

@caente Thanks, I see what you suggested for that one. This behavior works correctly using play json, the reason I am trying to use this lib instead is to support case classes larger than 22 fields.