Closed inteon closed 2 years ago
I skimmed their README file, and I'm fairly sure that all of those are possible on this API with minimal effort. For example, erroring on duplicate fields already happens by default, and erroring on unknown fields is supported via RejectUnknownMembers.
Case-sensitive matching is also used by default here. And syntactic errors have offsets: https://pkg.go.dev/github.com/go-json-experiment/json#SyntacticError
As for trying to decode JSON numbers into interface{}
as int64
, you could do that kind of customization via Unmarshalers: https://pkg.go.dev/github.com/go-json-experiment/json#example-UnmarshalOptions-RawNumber
Great, how about differentiating between strict and non-strict errors: https://github.com/kubernetes-sigs/json/blob/52af2062547443fa3cf74f6953fc77dee6331fc2/json.go#L96
They are different types in this API (syntactic vs semantic errors), so you can differentiate them pretty easily via Go type assertions.
One thing we don't support are "non-fatal" errors. The implementation currently eagerly stops upon the first semantic error encountered.
We decided to do eager error handling now, and provide an API in the future to opt-in to lazy errors. The problem with lazy errors is that multiple errors can occur and right now there is no standard way in Go to represent a list of errors. Eager errors avoids this issue since there can only be zero or one errors.
There's been recent discussion about multi errors upstream, so hopefully something useful comes out of that: golang/go#53435
It seems like there's nothing else to do or answer here, so I'm closing this for now.
FYI: in https://github.com/kubernetes-sigs/json Kubernetes hosts their patched version of
json
v1. Ideally, this implementation readily supports the features that were added in that repo.