Skip to content
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

fix: handle missing collection fields in JSON decoding #688

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

onyedikachi-david
Copy link

fixes #664
/closes #664
/claim #664

@onyedikachi-david onyedikachi-david requested a review from a team as a code owner June 9, 2024 00:20
@CLAassistant
Copy link

CLAassistant commented Jun 9, 2024

CLA assistant check
All committers have signed the CLA.

}

// Helper method to create an empty collection based on the schema
private def createEmptyCollection(schema: Schema[_]): Any =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this logic belongs to the trait Collection in Schema.scala, so each collection schema has to implement a method that creates an empty collection.

@@ -104,13 +104,13 @@ object JsonCodec {
def jsonEncoder[A](cfg: JsonCodec.Config)(schema: Schema[A]): ZJsonEncoder[A] =
JsonEncoder.schemaEncoder(schema, cfg)

def jsonDecoder[A](schema: Schema[A]): ZJsonDecoder[A] =
def jsonDecoder[A](schema: Schema[A])(implicit config: JsonCodec.Config): ZJsonDecoder[A] =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes are binary incompatible.
Config should not be implicit.
You should not reuse the same config value, since these are two different features. They should be configurable independent of each other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Json Codec: Read missing field as empty collection
3 participants