Skip to content

Commit

Permalink
rename encoder methods for the map type to respect JSON terms
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Feb 19, 2023
1 parent 1a32db9 commit 5e5766d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cli/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (e *encoder) encode(v any) error {
return err
}
case map[string]any:
if err := e.encodeMap(v); err != nil {
if err := e.encodeObject(v); err != nil {
return err
}
default:
Expand Down Expand Up @@ -185,7 +185,7 @@ func (e *encoder) encodeArray(vs []any) error {
return nil
}

func (e *encoder) encodeMap(vs map[string]any) error {
func (e *encoder) encodeObject(vs map[string]any) error {
e.writeByte('{', objectColor)
e.depth += e.indent
type keyVal struct {
Expand Down
4 changes: 2 additions & 2 deletions encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (e *encoder) encode(v any) {
case []any:
e.encodeArray(v)
case map[string]any:
e.encodeMap(v)
e.encodeObject(v)
default:
panic(fmt.Sprintf("invalid type: %[1]T (%[1]v)", v))
}
Expand Down Expand Up @@ -166,7 +166,7 @@ func (e *encoder) encodeArray(vs []any) {
e.w.WriteByte(']')
}

func (e *encoder) encodeMap(vs map[string]any) {
func (e *encoder) encodeObject(vs map[string]any) {
e.w.WriteByte('{')
type keyVal struct {
key string
Expand Down

0 comments on commit 5e5766d

Please sign in to comment.