Skip to content

Strictness on keyset match when reading / parsing to case class #537

@vreuter

Description

@vreuter

Hello! I have a test case that's failing at the moment, and the behavior suggests that it's because the presence of extra keys (beyond those corresponding to the fields of a case class) is not problematic when attempting to parse JSON to a value of the case class, when the reader in question is in scope by virtue of the case class having been written with a derives declaration.

  1. Is this true?
  2. If so, is there a way to get alternative, stricter parse behavior (i.e., require an exact match between the keyset in the JSON object being parsed, and the fields of the target case class), without writing a custom reader?

I understand the value of having more lax / less strict parsing behavior, particularly in the context of trait hierarchies, but in my case there's no hierarchy and I'd like to opt for stricter behavior if it's not too much additional effort. If it's helpful, I could describe the test case and why it suggests to me that the behavior is as I describe above.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions