Comments (5)
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.
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.
That's awesome, especially the priority over custom instances part. Thank you.
from circe.
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.
Using a package object at the root and declaring the package as such:
package myrootpackage
package foo
from circe.
Related Issues (20)
- Error is not correctly displayed for nested objects starting from 0.14.3 HOT 5
- Providing cats.Defer instances for Decoder and Encoder to make working with recursive structures easier HOT 2
- Support semiauto derivation without recursive derivation HOT 6
- Cannot derive `Decoder` for case class with inserction type fields HOT 1
- `BiggerDecimal.parseBiggerDecimalUnsafe` throws `NumberFormatException` HOT 1
- Bad encoding of Option in scala 2.12 HOT 1
- Decoding compilation fails for tagged types with Circe > 0.14.3 HOT 3
- Derivation doens't apply Configuration HOT 4
- Support new configuration that handles digit as a delimiter when converting to snake_case HOT 1
- How do I map a particular key and value in a custom way? HOT 2
- 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
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.