SIGN IN SIGN UP

encoding/json: mostly fix error offset regression

The documentation for Offset field in v1 errors says:

	error occurred after reading Offset bytes

This implies that the "Offset" should point after
the problematic text that led to the error.

Note that the v1 Offset differs from the v2 ByteOffset
where v2 consistently reports the offset right before
the problematic text that led to the error.
Analysis of how users currently use json errors today,
seems to indicate that they often do Offset-1 to obtain
an approximation of the starting offset of the error,
but this is technically incorrect since not all causes
of errors is due to the presence of a single character.

This CL tries to preserve v1 semantics of having Offset
report an offset that includes the problematic text.
Unfortunately, we cannot perfectly replicate v1 behavior
since it itself was inconsistent about whether it reported
an offset before or after the problem.

Fixes #79659

Change-Id: I832513e056c958c8bee68ece9c2e783554b33907
Reviewed-on: https://go-review.googlesource.com/c/go/+/785420
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
J
Joe Tsai committed
b9f39083eb55e7dd4ea0c9d254a0b0c70e17d2f9
Parent: 2e47ef6