Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Sep 24, 2023
1 parent 96e85b1 commit bb630a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions jsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func UnmarshalFrom(r io.Reader, v any) error {
return err
}
if d.More() {
return errX
return errMore
}
return nil
}

var errX = errors.New("body must contain only one JSON object")
var errMore = errors.New("body must contain only one JSON entity")
6 changes: 5 additions & 1 deletion jsn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ func TestUnmarshal(t *testing.T) {
},
{
input: `{"abc": 123}a`,
errStr: "body must contain only one JSON object",
errStr: "body must contain only one JSON entity",
},
{
input: `[123]{"a":"b"}`,
errStr: "body must contain only one JSON entity",
},
{
input: `{"abc`,
Expand Down

0 comments on commit bb630a0

Please sign in to comment.