From 67744023a45de9554dc51cfde12d74b30abc80f1 Mon Sep 17 00:00:00 2001 From: DevinZeng Date: Fri, 26 Apr 2024 19:28:54 +0800 Subject: [PATCH] add Rune.MarshalJSON for pretty display --- rune.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rune.go b/rune.go index df1cd50..21957cf 100644 --- a/rune.go +++ b/rune.go @@ -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 +}