mirror of
https://github.com/json-iterator/go.git
synced 2025-03-23 21:09:11 +02:00
add Any GetInterface
This commit is contained in:
parent
97472ecd96
commit
9abc2f52b0
@ -18,6 +18,7 @@ type Any interface {
|
||||
SetArray(newList []Any) bool
|
||||
GetObject() map[string]Any
|
||||
SetObject(map[string]Any) bool
|
||||
GetInterface() interface{}
|
||||
WriteTo(stream *Stream)
|
||||
Parse() *Iterator
|
||||
}
|
||||
|
@ -270,4 +270,9 @@ func (any *arrayLazyAny) WriteTo(stream *Stream) {
|
||||
any.fillCache()
|
||||
stream.WriteVal(any.cache)
|
||||
}
|
||||
}
|
||||
|
||||
func (any *arrayLazyAny) GetInterface() interface{} {
|
||||
any.fillCache()
|
||||
return any.cache
|
||||
}
|
@ -44,6 +44,10 @@ func (any *trueAny) Parse() *Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (any *trueAny) GetInterface() interface{} {
|
||||
return true
|
||||
}
|
||||
|
||||
type falseAny struct {
|
||||
baseAny
|
||||
}
|
||||
@ -87,3 +91,7 @@ func (any *falseAny) WriteTo(stream *Stream) {
|
||||
func (any *falseAny) Parse() *Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (any *falseAny) GetInterface() interface{} {
|
||||
return false
|
||||
}
|
||||
|
@ -73,4 +73,9 @@ func (any *floatLazyAny) ToString() string {
|
||||
|
||||
func (any *floatLazyAny) WriteTo(stream *Stream) {
|
||||
stream.Write(any.buf)
|
||||
}
|
||||
|
||||
func (any *floatLazyAny) GetInterface() interface{} {
|
||||
any.fillCache()
|
||||
return any.cache
|
||||
}
|
@ -76,6 +76,11 @@ func (any *intLazyAny) WriteTo(stream *Stream) {
|
||||
stream.Write(any.buf)
|
||||
}
|
||||
|
||||
func (any *intLazyAny) GetInterface() interface{} {
|
||||
any.fillCache()
|
||||
return any.cache
|
||||
}
|
||||
|
||||
type intAny struct {
|
||||
baseAny
|
||||
err error
|
||||
@ -120,4 +125,8 @@ func (any *intAny) WriteTo(stream *Stream) {
|
||||
|
||||
func (any *intAny) Parse() *Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (any *intAny) GetInterface() interface{} {
|
||||
return any.val
|
||||
}
|
@ -46,3 +46,7 @@ func (any *invalidAny) Get(path ...interface{}) Any {
|
||||
func (any *invalidAny) Parse() *Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (any *invalidAny) GetInterface() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
@ -42,4 +42,8 @@ func (any *nilAny) WriteTo(stream *Stream) {
|
||||
|
||||
func (any *nilAny) Parse() *Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (any *nilAny) GetInterface() interface{} {
|
||||
return nil
|
||||
}
|
@ -291,4 +291,9 @@ func (any *objectLazyAny) WriteTo(stream *Stream) {
|
||||
any.fillCache()
|
||||
stream.WriteVal(any.cache)
|
||||
}
|
||||
}
|
||||
|
||||
func (any *objectLazyAny) GetInterface() interface{} {
|
||||
any.fillCache()
|
||||
return any.cache
|
||||
}
|
@ -100,4 +100,9 @@ func (any *stringLazyAny) ToString() string {
|
||||
|
||||
func (any *stringLazyAny) WriteTo(stream *Stream) {
|
||||
stream.Write(any.buf)
|
||||
}
|
||||
|
||||
func (any *stringLazyAny) GetInterface() interface{} {
|
||||
any.fillCache()
|
||||
return any.cache
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user