You've already forked json-iterator
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:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user