forked from mirror/go-json
18 lines
333 B
Go
18 lines
333 B
Go
package json
|
|
|
|
import "bytes"
|
|
|
|
func Marshal(v interface{}) ([]byte, error) {
|
|
var b *bytes.Buffer
|
|
enc := NewEncoder(b)
|
|
defer enc.release()
|
|
return enc.encodeForMarshal(v)
|
|
}
|
|
|
|
func Unmarshal(data []byte, v interface{}) error {
|
|
src := make([]byte, len(data))
|
|
copy(src, data)
|
|
var dec Decoder
|
|
return dec.decodeForUnmarshal(src, v)
|
|
}
|