mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 04:42:33 +02:00
23 lines
391 B
Go
23 lines
391 B
Go
package json
|
|
|
|
import (
|
|
"reflect"
|
|
)
|
|
|
|
type Map[V any] map[string]V
|
|
|
|
func (m Map[V]) MarshalJSONTo(buf []byte) []byte {
|
|
oldN := len(buf)
|
|
buf = append(buf, '{')
|
|
for k, v := range m {
|
|
buf = AppendString(buf, k)
|
|
buf = append(buf, ':')
|
|
buf = appendMarshal(reflect.ValueOf(v), buf)
|
|
buf = append(buf, ',')
|
|
}
|
|
n := len(buf)
|
|
if oldN != n {
|
|
buf = buf[:n-1]
|
|
}
|
|
return append(buf, '}')
|
|
}
|