-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Encoding Decoding Map to JSON #447
Comments
I checked the Spec and I see Map is encoded as a sequence of tuples like: [
{"key1": value1},
{"key2": value2}
] However the expectation for me is: {
"key1": value1,
"key2": value2
} I think we should change the full implementation of Map encoder/decoder not just the default values |
@jdegoes @thinkharderdev @devsprint @tusharmath This is a big problem to use in any API, I have to receive/pass very often Map[String, String] for extra configuration (for example if you use Spark) and it's really weird that is mapped to json [] instead of {} I implemented a library for ArangoDB using zio-http and zio-json for serialization and I'm now trying to support zio-schema on top of that (so you can use ArangoDB with any type that has an Schema, and I plan to do dynamic graph queries that bring more than 1 entity just from the Schema abstraction) |
@jdegoes @thinkharderdev @devsprint @tusharmath I finally had time to implement the full code, to start I only apply the new encoder/decoder when the Map has String as key We can apply more improvements on next PRs if you think is worth it:
|
/bounty $75 |
💎 $75 bounty • ZIOSteps to solve:
Thank you for contributing to zio/zio-schema! Add a bounty • Share on socials
|
I think this was fixed on previous PR @jdegoes |
/attempt #447 Options |
@Samankhalid01: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏 |
The bounty is up for grabs! Everyone is welcome to |
@adamgfraser , maybe you want to claim the bounty for this, based on #531? |
@jdegoes this issue still pops up on algora as an open bounty. Maybe you can remove the bounty? |
How to reproduce, create a case class with an optional field of type Map:
Expected test to pass:
Error: the field details is decoded as
Map("" -> "" )
instead ofMap.empty
:I tried also with next annotations:
The text was updated successfully, but these errors were encountered: