diff options
| author | Joe Tsai <joetsai@digital-static.net> | 2025-10-21 10:39:15 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-10-24 09:05:36 -0700 |
| commit | a6a59f0762787fd50c7069b77b0addbc2339c8d2 (patch) | |
| tree | f4ee63b23e69ac795af9a524fbb267418c92d2c9 /src/encoding/json/v2/errors.go | |
| parent | 0d3dab9b1d3b22ecac956c79a1b42a7d3f587c06 (diff) | |
| download | go-a6a59f0762787fd50c7069b77b0addbc2339c8d2.tar.xz | |
encoding/json/v2: use slices.Sort directly
This is semantically identical and just a cleanup.
Prior to #63397, JSON object names were sorted according to UTF-16
to match the semantic of RFC 8785, but there were a number of
objections in the discussion to using that as the sorting order.
In https://github.com/go-json-experiment/json/pull/121,
we switched to sorting by UTF-8, which matches the behavior
of v1 and avoids an option to toggle the behavior.
However, we should have deleted the stringSlice.Sort method
and just directly called slices.Sort.
From a principled perspective, both UTF-16 and UTF-8 are
reasonable ways to sort JSON object names.
RFC 8259 specifies that the entire JSON text is encoded as UTF-8.
However, the way JSON strings are encoded requires escaping
Unicode codepoints according to UTF-16 surragate halves
(a quirk of JavaScript inherited by JSON).
Thus, JSON is inconsistently both UTF-8 and UTF-16.
Change-Id: Id92b5cc20efe4201827e9d3fccf24ccf894d3e60
Reviewed-on: https://go-review.googlesource.com/c/go/+/713522
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Bypass: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Daniel Martà <mvdan@mvdan.cc>
Reviewed-by: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/encoding/json/v2/errors.go')
0 files changed, 0 insertions, 0 deletions
