@@ -74,12 +74,17 @@ func (v JSONValue) AsArray() []JSONValue {
74
74
return v .Value .([]JSONValue )
75
75
}
76
76
77
+ var (
78
+ _ json.Unmarshaler = (* JSONValue )(nil )
79
+ _ json2.UnmarshalerFrom = (* JSONValue )(nil )
80
+ )
81
+
77
82
func (v * JSONValue ) UnmarshalJSON (data []byte ) error {
78
83
return unmarshalJSONValue [JSONValue ](v , data )
79
84
}
80
85
81
- func (v * JSONValue ) UnmarshalJSONV2 (dec * jsontext.Decoder , opts json2. Options ) error {
82
- return unmarshalJSONValueV2 [JSONValue ](v , dec , opts )
86
+ func (v * JSONValue ) UnmarshalJSONFrom (dec * jsontext.Decoder ) error {
87
+ return unmarshalJSONValueV2 [JSONValue ](v , dec )
83
88
}
84
89
85
90
func unmarshalJSONValue [T any ](v * JSONValue , data []byte ) error {
@@ -115,7 +120,7 @@ func unmarshalJSONValue[T any](v *JSONValue, data []byte) error {
115
120
return nil
116
121
}
117
122
118
- func unmarshalJSONValueV2 [T any ](v * JSONValue , dec * jsontext.Decoder , opts json2. Options ) error {
123
+ func unmarshalJSONValueV2 [T any ](v * JSONValue , dec * jsontext.Decoder ) error {
119
124
switch dec .PeekKind () {
120
125
case 'n' : // jsontext.Null.Kind()
121
126
if _ , err := dec .ReadToken (); err != nil {
@@ -126,17 +131,17 @@ func unmarshalJSONValueV2[T any](v *JSONValue, dec *jsontext.Decoder, opts json2
126
131
return nil
127
132
case '"' :
128
133
v .Type = JSONValueTypeString
129
- if err := json2 .UnmarshalDecode (dec , & v .Value , opts ); err != nil {
134
+ if err := json2 .UnmarshalDecode (dec , & v .Value ); err != nil {
130
135
return err
131
136
}
132
137
case '[' :
133
138
if _ , err := dec .ReadToken (); err != nil {
134
139
return err
135
140
}
136
141
var elements []T
137
- for dec .PeekKind () != jsontext .ArrayEnd .Kind () {
142
+ for dec .PeekKind () != jsontext .EndArray .Kind () {
138
143
var element T
139
- if err := json2 .UnmarshalDecode (dec , & element , opts ); err != nil {
144
+ if err := json2 .UnmarshalDecode (dec , & element ); err != nil {
140
145
return err
141
146
}
142
147
elements = append (elements , element )
@@ -148,19 +153,19 @@ func unmarshalJSONValueV2[T any](v *JSONValue, dec *jsontext.Decoder, opts json2
148
153
v .Value = elements
149
154
case '{' :
150
155
var object collections.OrderedMap [string , T ]
151
- if err := json2 .UnmarshalDecode (dec , & object , opts ); err != nil {
156
+ if err := json2 .UnmarshalDecode (dec , & object ); err != nil {
152
157
return err
153
158
}
154
159
v .Type = JSONValueTypeObject
155
160
v .Value = & object
156
161
case 't' , 'f' : // jsontext.True.Kind(), jsontext.False.Kind()
157
162
v .Type = JSONValueTypeBoolean
158
- if err := json2 .UnmarshalDecode (dec , & v .Value , opts ); err != nil {
163
+ if err := json2 .UnmarshalDecode (dec , & v .Value ); err != nil {
159
164
return err
160
165
}
161
166
default :
162
167
v .Type = JSONValueTypeNumber
163
- if err := json2 .UnmarshalDecode (dec , & v .Value , opts ); err != nil {
168
+ if err := json2 .UnmarshalDecode (dec , & v .Value ); err != nil {
164
169
return err
165
170
}
166
171
}
0 commit comments