Joseph Tsai submitted the change![Open in Gerrit]()
Change information
Commit message:
encoding/json/v2: allow streaming JSON methods to return errors.ErrUnsupported
Allow the MarshalJSONTo and UnmarshalJSONFrom methods
to return errors.ErrUnsupported to be skipped in a similar manner
to how the caller-specified functions can be skipped as well.
Note that the v1 MarshalJSON and UnmarshalJSON methods may not
return errors.ErrUnsupported as that would be a breaking change.
Also, we couldn't implement it for UnmarshalJSON since
that requires consuming the value, which changes the state of
the underlying jsontext.Decoder.
A side-effect of this change is that MarshalJSONTo and UnmarshalJSONFrom
methods may now return sentinel errors. We document that users
should avoid calling this methods directly and instead
rely on MarshalEncode and UnmarshalDecode,
which can handle the ErrUnsupported sentinel error and
others that we may add in the future.
Fixes #74324
Fixes #76712
Change-Id: I851e907ef8d25e31964148515879a243cb5069c5
Files:
- M src/encoding/json/v2/arshal.go
- M src/encoding/json/v2/arshal_methods.go
- M src/encoding/json/v2/arshal_test.go
Change size: M
Delta: 3 files changed, 55 insertions(+), 13 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +1 by Junyang Shao, +2 by Damien Neil, +2 by Johan Brandhorst-Satzkorn
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I851e907ef8d25e31964148515879a243cb5069c5
Gerrit-Change-Number: 744941
Gerrit-PatchSet: 2