GithubHelp home page GithubHelp logo

Comments (5)

travisbrown avatar travisbrown commented on July 22, 2024 2

I'm going to reopen this issue because I can imagine providing explicit support for this—e.g. something like:

import io.circe.generic._, io.circe.generic.config._

val deriver: ConfiguredDeriver[SnakeCaseKeys] = ConfiguredDeriver[SnakeCaseKeys]

import deriver._

I'm not 100% sure I like this, but I think it's worth discussing.

from circe.

travisbrown avatar travisbrown commented on July 22, 2024

It's possible to do this now:

import io.circe._, io.circe.generic.auto._, io.circe.generic.config._

implicit def snakeCaseDecoder[A](implicit
  decoder: ConfiguredDecoder[SnakeCaseKeys, A]
): export.Export0[Decoder[A]] = new export.Export0(decoder)

This exports instances configured to use snake-case at a higher priority that the default for exported instances. These won't take priority over custom instances, but they do outrank the default unconfigured derived instances.

(Note that this is just a demonstration—in real code you'd probably want to define something like a SnakeCaseDecoder subclass of Decoder and export instances with @exports(HighPriority)).

from circe.

dwijnand avatar dwijnand commented on July 22, 2024

That's awesome, especially the priority over custom instances part. Thank you.

from circe.

onsails avatar onsails commented on July 22, 2024

That would be great to be able to make the whole scope to use snake case keys because usually APIs accept keys encoded in exactly one style.

from circe.

dwijnand avatar dwijnand commented on July 22, 2024

Using a package object at the root and declaring the package as such:

package myrootpackage
package foo

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.