Comments (5)
from circe.
The behavior is as expected. 'semi-auto' derivation should not do nested case classes.
from circe.
see also #2248
from circe.
#2138 should fix this.
from circe.
I can confirm this issue seems to be resolved.
However, I need to add an additional decoder for Location
to make it work.
Updated Code
package 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
Left(DecodingFailure at .location.city: Missing required field)
Left(DecodingFailure at .location.city: Missing required field)
Ommitting Location Decoder
For some reason, it's no longer possible to derive nested case classes. You'll end up with the error below:
Could not find Lazy implicit value of type io.circe.generic.decoding.DerivedDecoder[org.my.Main.Person]
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 Person
but the Location
which could not be found.
from circe.
Related Issues (20)
- io.circe.pointer.literal.PointerInterpolatorSuite seems Flaky (or there's a bug?) HOT 2
- Maximal number of successive inlines (32) exceeded, Maybe this is caused by a recursive inline method? HOT 7
- Circe cannot decode output from auto-derived codec on Scala 3 HOT 1
- Scala3 derivation incorrectly assumes collection type for generic class HOT 4
- Stack overflow on 0.14.6 HOT 4
- Unexpected derivation of Encoder[Option[T]]
- Modifying JsonObject using ACursor/HCursor performance hit due to megamorphic calls HOT 1
- Invalid Json tree with `null` (java) values, NPE in printer HOT 1
- a problem with current derivations HOT 7
- Properly parse JSON object key with quotes HOT 1
- usage of ISO_ZONED_DATE_TIME as default formatter in encoder HOT 3
- Scala 2.13: derivedConfiguratedEncoder becomes unconfigured under some conditions HOT 1
- Expected `json` string interpolator from io.circe.literal to be able to interpolate variable inside of value strings HOT 2
- Invalid pathToRoot for `missing required field` validation error HOT 2
- flaky test PointerInterpolatorSuite HOT 2
- `StackOverflowError` if local class since 0.14.7 with Scala 3 HOT 2
- Adjust contrast of website nav menu colours
- Refined version update for JS and JVM HOT 4
- Move refined into its own repo with its own release cycle
- Scala 3 Inconsistent Application of Configuration Discriminator
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from circe.