1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00

fix 4 fields object decoding

This commit is contained in:
Tao Wen
2017-01-06 20:17:47 +08:00
parent c70437c6b9
commit 101dfdbb2a
10 changed files with 2113 additions and 285 deletions

View File

@ -1,6 +1,9 @@
package jsoniter
import "io"
import (
"io"
"unsafe"
)
// Unmarshal adapts to json/encoding APIs
func Unmarshal(data []byte, v interface{}) error {
@ -11,3 +14,13 @@ func Unmarshal(data []byte, v interface{}) error {
}
return iter.Error
}
func UnmarshalString(str string, v interface{}) error {
data := *(*[]byte)(unsafe.Pointer(&str))
iter := ParseBytes(data)
iter.Read(v)
if iter.Error == io.EOF {
return nil
}
return iter.Error
}