[go] encoding/json: fix Decoder.InputOffset regression in goexperiment.jsonv2

0 views
Skip to first unread message

Joseph Tsai (Gerrit)

unread,
2:03 AM (2 hours ago) 2:03 AM
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Junyang Shao, Damien Neil, Go LUCI, golang-co...@googlegroups.com

Joseph Tsai submitted the change

Change information

Commit message:
encoding/json: fix Decoder.InputOffset regression in goexperiment.jsonv2

The Decoder.InputOffset method was always ambiguous about the exact
offset returned since anything between the end of the previous token
to the start of the next token could be a valid result.

Empirically, it seems that the behavior was to report
the end of the previous token unless Decoder.More is called,
in which case it reports the start of the next token.

This is an odd semantic since a relatively side-effect free method
like More is not quite so side-effect free.
However, our goal is to preserve historical v1 semantic when possible
regardless of whether it made sense.

Note that jsontext.Decoder.InputOffset consistently always reports
the end of the previous token. Users can explicitly choose the
exact position they want by inspecting the UnreadBuffer.

Fixes #75468
Change-Id: I1e946e83c9d29dfc09f2913ff8d6b2b80632f292
Reviewed-by: Damien Neil <dn...@google.com>
Reviewed-by: Junyang Shao <shaoj...@google.com>
Files:
  • M src/encoding/json/stream_test.go
  • M src/encoding/json/v2_stream.go
  • M src/encoding/json/v2_stream_test.go
Change size: M
Delta: 3 files changed, 149 insertions(+), 1 deletion(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Junyang Shao, +2 by Damien Neil
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I1e946e83c9d29dfc09f2913ff8d6b2b80632f292
Gerrit-Change-Number: 703856
Gerrit-PatchSet: 5
Gerrit-Owner: Joseph Tsai <joe...@digital-static.net>
Gerrit-Reviewer: Damien Neil <dn...@google.com>
Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages