Skip to content

Commit

Permalink
Merge pull request #7 from wuzhidan2021/patch-1
Browse files Browse the repository at this point in the history
Update marshal.go
  • Loading branch information
dozen authored Sep 30, 2022
2 parents 527920f + e0f38e6 commit 83bbc67
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,23 @@ func (e *Encoder) marshal(v interface{}) error {
return err
}
}
case reflect.Map:
e.w.WriteByte(HASH_SIGN)
err := e.encInt(val.Len())
if err != nil {
return err
}
iter := val.MapRange()
for iter.Next() {
err = e.marshal(iter.Key().Interface())
if err != nil {
return err
}
err = e.marshal(iter.Value().Interface())
if err != nil {
return err
}
}
}
return fmt.Errorf("cannot marshal value of type %v", typ.Kind())
}
Expand Down

0 comments on commit 83bbc67

Please sign in to comment.