You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-06-15 22:50:24 +02:00
suport encode interface
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type arrayLazyAny struct {
|
||||
baseAny
|
||||
buf []byte
|
||||
@ -231,3 +235,26 @@ func (any *arrayLazyAny) IterateArray() (func() (Any, bool), bool) {
|
||||
}
|
||||
}, true
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (any *arrayLazyAny) GetArray() []Any {
|
||||
any.fillCache()
|
||||
return any.cache
|
||||
}
|
||||
|
||||
func (any *arrayLazyAny) SetArray(newList []Any) bool {
|
||||
any.fillCache()
|
||||
any.cache = newList
|
||||
return true
|
||||
}
|
||||
|
||||
func (any *arrayLazyAny) WriteTo(stream *Stream) {
|
||||
if len(any.remaining) == len(any.buf) {
|
||||
// nothing has been parsed yet
|
||||
stream.WriteRaw(*(*string)(unsafe.Pointer(&any.buf)))
|
||||
} else {
|
||||
any.fillCache()
|
||||
stream.WriteVal(any.cache)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user