It's recommended to implement toEncoding when instantiating ToJSON, but there's no validation ensuring it agrees with toJSON (which is a requirement since it doesn't go the other way).
A simple workaround might be to encode toJSON v and v both while testing round tripping. They don't need to end with identical representations, but the decoder needs to agree that they're equivalent.
It's recommended to implement
toEncoding
when instantiatingToJSON
, but there's no validation ensuring it agrees withtoJSON
(which is a requirement since it doesn't go the other way).A simple workaround might be to encode
toJSON v
andv
both while testing round tripping. They don't need to end with identical representations, but the decoder needs to agree that they're equivalent.