GithubHelp home page GithubHelp logo

Comments (8)

travisbrown avatar travisbrown commented on July 22, 2024 1

@trane It's not necessarily obvious that a derived decoder will use default constructor values (when they're needed), and if that's not the behavior you want, it could be an unpleasant surprise. But I agreeโ€”I think it makes sense to use them (with plenty of documentation) in auto, and to provide something like decoderWithoutDefaults in semiauto.

from circe.

travisbrown avatar travisbrown commented on July 22, 2024 1

This is now available in circe-extras in 0.6.0-RC1.

from circe.

alexarchambault avatar alexarchambault commented on July 22, 2024

Something like milessabin/shapeless#459 would allow to address that (default field values can easily be pulled like in this test).

from circe.

travisbrown avatar travisbrown commented on July 22, 2024

One general question: should this be the behavior provided by generic.auto (if default values are available in the Default instance, use them), or should it be an option provided by semiauto?โ€”i.e. something like this:

implicit val decodeBar: Decoder[Bar] = deriveFor[Bar].decoderWithDefaults

from circe.

trane avatar trane commented on July 22, 2024

I don't know what the benefit is to having it in semiauto. The least surprising option, from my point of view, is to treat case class X with/without defaults the same way.

from circe.

trane avatar trane commented on July 22, 2024

@travisbrown don't trust my point of view, I've been coding in Ruby for the past 2 years -- of course I like magic and surprising behavior!

from circe.

LATaylor-guardian avatar LATaylor-guardian commented on July 22, 2024

@travisbrown @trane Was this ever added by any chance? I was playing around this morning and hit this issue so was unsure if I am missing something?

from circe.

ilya-murzinov avatar ilya-murzinov commented on July 22, 2024

@travisbrown I was figuring out how it can be implemented and ended up with the following.
Inside DerivationMacros#decodeHList and DerivationMacros#decodeCoproduct we should check whether the class has default values, and if it has, add them to representation.
Am I on the right path?
If so, can you give any tips in how it can be done?

from circe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.