This behaviour is "correct" (it's noted by rfc8259 as a possible behaviour), but I would nontheless like to detect this scenario and raise an exception - silently discarding information is undesirable for my use case.
Python's built-in JSON module can be extended to perform this checking like so: https://gist.github.com/DavidBuchanan314/bf57251b2519c5ea55042fc4af62e033, and ideally I'd like similar functionality from msgspec (I don't care about object_pairs_hook specifically, just the ability to check dupes).
Description
When decoding plain JSON with duplicate keys, all but the last are silently ignored, for example:
This behaviour is "correct" (it's noted by rfc8259 as a possible behaviour), but I would nontheless like to detect this scenario and raise an exception - silently discarding information is undesirable for my use case.
Python's built-in JSON module can be extended to perform this checking like so: https://gist.github.com/DavidBuchanan314/bf57251b2519c5ea55042fc4af62e033, and ideally I'd like similar functionality from msgspec (I don't care about
object_pairs_hook
specifically, just the ability to check dupes).p.s. this feature has also been requested (and closed as stale) in orjson ;) https://github.com/ijl/orjson/issues/456