Open henricook opened 4 years ago
Looking through the MRs I think this is what introduced the breaking change - https://github.com/xdotai/play-json-extensions/pull/74/files
Can this issue remain as a reminder the readme needs to be updated? I think I should be using 'BaseNameEncoder' to retain previous behaviour but i'm not sure? Is that right?
Like @henricook , I had to explore the source to fix the problem. In case anyone else is stuck here's a solution:
import ai.x.play.json.{BaseNameEncoder, Jsonx, NameEncoder}
import play.api.libs.json.{Json, OFormat}
case class Foo(a1: String, a2: String, a3: String, a4: String, a5: String,
a6: String, a7: String, a8: String, a9: String, a10: String,
a11: String, a12: String, a13: String, a14: String, a15: String,
a16: String, a17: String, a18: String, a19: String, a20: String,
a21: String, a22: String, a23: String)
object Foo {
implicit val e: NameEncoder = BaseNameEncoder.apply()
implicit val f: OFormat[Foo] = Jsonx.formatCaseClass[Foo]
def empty(): Foo = {
this ("", "", "", "", "",
"", "", "", "", "",
"", "", "", "", "",
"", "", "", "", "",
"", "", "")
}
}
object MainObject {
def main(args: Array[String]): Unit = {
println(Json.toJson(Foo.empty()).as[Map[String, String]])
}
}
Thanks for the pointers. I found a slightly tidier solution - adding this import.
import ai.x.play.json.Encoders.encoder
Hi all,
When upgrading to 0.42.0...
With a straightforward case class of only
Boolean
fieldsIt's not clear from the docs or open issues what to do about it, can anyone help? Is it a bug?