-
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
Ways to ignore empty collections while encoding json #605
Conversation
f4e6de1
to
4b8457e
Compare
@987Nabil Overall looks good. I am not a fan of the implicit config pattern. Do we have to make that config implicit? |
@jdegoes I guess we can have overloaded methods with a config parameter. So we don't break compatibility. |
4b8457e
to
67936bb
Compare
@@ -58,7 +65,7 @@ object JsonCodec { | |||
) | |||
} | |||
|
|||
implicit def schemaBasedBinaryCodec[A](implicit schema: Schema[A]): BinaryCodec[A] = | |||
implicit def schemaBasedBinaryCodec[A](implicit schema: Schema[A], cfg: Config): BinaryCodec[A] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now Config.default
is no longer implicit, but here it is an implicit parameter which makes this a bit inconvenient. I suggest to keep an implicit def schemaBasedBinaryCodec
with only schema parameter, always using Config.default
, so users who want to customize it can use the explicit version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh sorry, I missed that part. I did it for the other methods. How you wrote it, was how I planned it.
67936bb
to
6135e77
Compare
6135e77
to
c97c3dd
Compare
347fc58
to
e92fac1
Compare
This pr introduces a config for the JsonCodec, to set behaviour on the codec creation level instead of classes via annotations. We can use this to configure default behaviour in zio-http for example via user config.
Or could make it the default of zio-http to ignore empty collection fields during encoding, without messing with the defaults of zio-schema.