-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error is not correctly displayed for nested objects starting from 0.14.3 #2113
Comments
see also #2248 |
#2138 should fix this. |
I can confirm this issue seems to be resolved. However, I need to add an additional decoder for Updated Codepackage org.my
import cats.implicits._
import io.circe._
import io.circe.generic.semiauto._
import io.circe.parser.decode
object Main extends App {
case class Location(city: String)
case class Person(name: String, location: Location)
val jsonString =
"""{
| "name": "John",
| "location": {
| }
|}""".stripMargin
implicit val locationDecoder: Decoder[Location] = deriveDecoder[Location]
implicit val personDecoder: Decoder[Person] = deriveDecoder[Person]
val result = decode[Person](jsonString)
println(result)
println(result.left.map(_.show))
} Output
Ommitting Location DecoderFor some reason, it's no longer possible to derive nested case classes. You'll end up with the error below:
I'll close this issue, as the issue has been resolved. It would be nice if the error was more precise, though. It's not the |
The behavior is as expected. 'semi-auto' derivation should not do nested case classes. |
I noticed that the error message is sometimes incorrect when decoding nested objects.
For 0.14.2 it works as expected because it's clear where the missing property comes from (i.e.
.location.city
):For 0.14.3 it doesn't work as expected as the root (
.location
) seems to be missing only in the.show
:For 0.14.4 and 0.14.5 the output is as follows where both miss the root object (i.e.
.location
):The text was updated successfully, but these errors were encountered: