File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,13 @@ func (f F) MarshalJSON() ([]byte, error) {
38
38
39
39
// Unmarshal only 1 JSON entity from the input.
40
40
// Disallows unknown fields if the argument is a struct.
41
- func Unmarshal (r io.Reader , v any ) error {
41
+ func Unmarshal (b []byte , v any ) error {
42
+ return UnmarshalFrom (bytes .NewReader (b ), v )
43
+ }
44
+
45
+ // UnmarshalFrom reader only 1 JSON entity from the input.
46
+ // Disallows unknown fields if the argument is a struct.
47
+ func UnmarshalFrom (r io.Reader , v any ) error {
42
48
d := json .NewDecoder (r )
43
49
d .DisallowUnknownFields ()
44
50
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ func TestUnmarshal(t *testing.T) {
47
47
48
48
for _ , tc := range testCases {
49
49
var val any
50
- err := UnmarshalBytes ([]byte (tc .input ), & val )
50
+ err := Unmarshal ([]byte (tc .input ), & val )
51
51
if err != nil {
52
52
if tc .errStr == "" {
53
53
t .Fatal (err )
You can’t perform that action at this time.
0 commit comments