aboutsummaryrefslogtreecommitdiff
path: root/src/encoding
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding')
-rw-r--r--src/encoding/json/internal/jsonopts/options.go8
-rw-r--r--src/encoding/json/internal/jsonopts/options_test.go3
-rw-r--r--src/encoding/json/v2/options.go5
-rw-r--r--src/encoding/json/v2_options.go4
4 files changed, 10 insertions, 10 deletions
diff --git a/src/encoding/json/internal/jsonopts/options.go b/src/encoding/json/internal/jsonopts/options.go
index e4c3f47d36..39da81b345 100644
--- a/src/encoding/json/internal/jsonopts/options.go
+++ b/src/encoding/json/internal/jsonopts/options.go
@@ -48,16 +48,16 @@ type ArshalValues struct {
// DefaultOptionsV2 is the set of all options that define default v2 behavior.
var DefaultOptionsV2 = Struct{
Flags: jsonflags.Flags{
- Presence: uint64(jsonflags.AllFlags & ^jsonflags.WhitespaceFlags),
- Values: uint64(0),
+ Presence: uint64(jsonflags.DefaultV1Flags),
+ Values: uint64(0), // all flags in DefaultV1Flags are false
},
}
// DefaultOptionsV1 is the set of all options that define default v1 behavior.
var DefaultOptionsV1 = Struct{
Flags: jsonflags.Flags{
- Presence: uint64(jsonflags.AllFlags & ^jsonflags.WhitespaceFlags),
- Values: uint64(jsonflags.DefaultV1Flags),
+ Presence: uint64(jsonflags.DefaultV1Flags),
+ Values: uint64(jsonflags.DefaultV1Flags), // all flags in DefaultV1Flags are true
},
}
diff --git a/src/encoding/json/internal/jsonopts/options_test.go b/src/encoding/json/internal/jsonopts/options_test.go
index ebfaf05c83..caa686e4f0 100644
--- a/src/encoding/json/internal/jsonopts/options_test.go
+++ b/src/encoding/json/internal/jsonopts/options_test.go
@@ -200,6 +200,9 @@ func TestGet(t *testing.T) {
if v, ok := json.GetOption(opts, json.WithUnmarshalers); v != nil || ok {
t.Errorf(`GetOption(..., WithUnmarshalers) = (%v, %v), want (nil, false)`, v, ok)
}
+ if v, ok := json.GetOption(json.DefaultOptionsV2(), json.WithMarshalers); v != nil || ok {
+ t.Errorf(`GetOption(..., WithMarshalers) = (%v, %v), want (nil, false)`, v, ok)
+ }
}
var sink struct {
diff --git a/src/encoding/json/v2/options.go b/src/encoding/json/v2/options.go
index 0942d2d307..9685f20f9f 100644
--- a/src/encoding/json/v2/options.go
+++ b/src/encoding/json/v2/options.go
@@ -97,9 +97,8 @@ func GetOption[T any](opts Options, setter func(T) Options) (T, bool) {
}
// DefaultOptionsV2 is the full set of all options that define v2 semantics.
-// It is equivalent to all options under [Options], [encoding/json.Options],
-// and [encoding/json/jsontext.Options] being set to false or the zero value,
-// except for the options related to whitespace formatting.
+// It is equivalent to the set of options in [encoding/json.DefaultOptionsV1]
+// all being set to false. All other options are not present.
func DefaultOptionsV2() Options {
return &jsonopts.DefaultOptionsV2
}
diff --git a/src/encoding/json/v2_options.go b/src/encoding/json/v2_options.go
index 819fe59f41..2bdec86fde 100644
--- a/src/encoding/json/v2_options.go
+++ b/src/encoding/json/v2_options.go
@@ -227,9 +227,7 @@ type Options = jsonopts.Options
// - [jsontext.EscapeForJS]
// - [jsontext.PreserveRawStrings]
//
-// All other boolean options are set to false.
-// All non-boolean options are set to the zero value,
-// except for [jsontext.WithIndent], which defaults to "\t".
+// All other options are not present.
//
// The [Marshal] and [Unmarshal] functions in this package are
// semantically identical to calling the v2 equivalents with this option: