Skip to content

Commit

Permalink
add Rune.MarshalJSON for pretty display
Browse files Browse the repository at this point in the history
  • Loading branch information
studyzy committed Apr 26, 2024
1 parent fb88a65 commit 6774402
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rune.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,8 @@ func (e Error) Error() string {
}
return fmt.Sprintf("invalid character `%c`", e.Character)
}

// MarshalJSON json marshal
func (r Rune) MarshalJSON() ([]byte, error) {
return []byte(`"` + r.String() + `"`), nil
}

0 comments on commit 6774402

Please sign in to comment.