Skip to content

Commit

Permalink
[BREAKING CHANGE] Rename unmarshal funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Dec 9, 2023
1 parent 1b4f5f9 commit da15aec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions jsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ func (n N) MarshalJSON() ([]byte, error) {
return []byte(n), nil
}

// Unmarshal only 1 JSON entity from the input.
// UnmarshalBytes only 1 JSON entity from the input.
// Disallows unknown fields if the argument is a struct.
func Unmarshal(b []byte, v any) error {
return UnmarshalFrom(bytes.NewReader(b), v)
func UnmarshalBytes(b []byte, v any) error {
return Unmarshal(bytes.NewReader(b), v)
}

// UnmarshalFrom only 1 JSON entity from the input.
// Unmarshal only 1 JSON entity from the input.
// Disallows unknown fields if the argument is a struct.
func UnmarshalFrom(r io.Reader, v any) error {
func Unmarshal(r io.Reader, v any) error {
d := json.NewDecoder(r)
d.DisallowUnknownFields()

Expand Down
2 changes: 1 addition & 1 deletion jsn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestUnmarshal(t *testing.T) {

for _, tc := range testCases {
var val any
err := Unmarshal([]byte(tc.input), &val)
err := UnmarshalBytes([]byte(tc.input), &val)
if err != nil {
if tc.errStr == "" {
t.Fatal(err)
Expand Down

0 comments on commit da15aec

Please sign in to comment.