mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-11 08:52:27 +08:00
20 lines
392 B
Go
20 lines
392 B
Go
package jsonutil
|
|
|
|
import (
|
|
"encoding/json"
|
|
"reflect"
|
|
"unsafe"
|
|
)
|
|
|
|
// ----------------------------------------------------------
|
|
|
|
func Unmarshal(data string, v interface{}) error {
|
|
|
|
sh := *(*reflect.StringHeader)(unsafe.Pointer(&data))
|
|
arr := (*[1<<30]byte)(unsafe.Pointer(sh.Data))
|
|
return json.Unmarshal(arr[:sh.Len], v)
|
|
}
|
|
|
|
// ----------------------------------------------------------
|
|
|