zio / zio-json

Fast, secure JSON library with tight ZIO integration.
https://zio.dev/zio-json
Apache License 2.0
401 stars 143 forks source link

Feat-string-like-field-decoder #1137

Open ThijsBroersen opened 1 week ago

ThijsBroersen commented 1 week ago

This PR should provide support for string-like types (T <: String) to be used as keys in json objects. The implementation reuses any applicable existing JsonDecoder, e.g. a decoder for a string-based const union.

Foo(aOrB: Map["A" | "B", Int]) derives JsonDecoder

value encoded/decoded

Foo(Map("A" -> 1, "B" -> 2))

json

{"aOrB":{"A":1,"B":2}}