refactor: yet another one, someday I might be happy

This commit is contained in:
2024-03-24 03:28:08 +00:00
parent ccc3668fa2
commit de3a9e55a8
18 changed files with 613 additions and 499 deletions

12
json.go
View File

@@ -24,11 +24,11 @@ type JSON struct {
var _ FormatRenderer = (*JSON)(nil)
// Render marshals the given value to JSON.
func (j *JSON) Render(w io.Writer, v any) error {
func (jr *JSON) Render(w io.Writer, v any) error {
enc := json.NewEncoder(w)
if j.Pretty {
prefix := j.Prefix
indent := j.Indent
if jr.Pretty {
prefix := jr.Prefix
indent := jr.Indent
if indent == "" {
indent = " "
}
@@ -43,3 +43,7 @@ func (j *JSON) Render(w io.Writer, v any) error {
return nil
}
func (jr *JSON) Formats() []string {
return []string{"json"}
}