1
0
mirror of https://github.com/json-iterator/go.git synced 2024-11-24 08:22:14 +02:00
json-iterator/feature_any_invalid.go

85 lines
1.3 KiB
Go
Raw Normal View History

2017-01-23 02:33:43 +02:00
package jsoniter
2017-01-26 10:24:01 +02:00
import "fmt"
2017-01-23 02:33:43 +02:00
type invalidAny struct {
baseAny
2017-01-26 10:24:01 +02:00
err error
2017-01-23 02:33:43 +02:00
}
func newInvalidAny(path []interface{}) *invalidAny {
return &invalidAny{baseAny{}, fmt.Errorf("%v not found", path)}
}
2017-01-23 02:33:43 +02:00
func (any *invalidAny) LastError() error {
2017-01-26 10:24:01 +02:00
return any.err
}
func (any *invalidAny) ValueType() ValueType {
return Invalid
2017-01-23 02:33:43 +02:00
}
2017-06-19 15:21:20 +02:00
func (any *invalidAny) MustBeValid() Any {
panic(any.err)
return any
}
2017-01-23 02:33:43 +02:00
func (any *invalidAny) ToBool() bool {
return false
}
func (any *invalidAny) ToInt() int {
return 0
}
func (any *invalidAny) ToInt32() int32 {
return 0
}
func (any *invalidAny) ToInt64() int64 {
return 0
}
2017-01-29 10:55:32 +02:00
func (any *invalidAny) ToUint() uint {
return 0
}
func (any *invalidAny) ToUint32() uint32 {
return 0
}
func (any *invalidAny) ToUint64() uint64 {
return 0
}
2017-01-23 02:33:43 +02:00
func (any *invalidAny) ToFloat32() float32 {
return 0
}
func (any *invalidAny) ToFloat64() float64 {
return 0
}
func (any *invalidAny) ToString() string {
return ""
}
2017-01-26 08:56:31 +02:00
func (any *invalidAny) WriteTo(stream *Stream) {
}
func (any *invalidAny) Get(path ...interface{}) Any {
2017-01-26 10:24:01 +02:00
if any.err == nil {
return &invalidAny{baseAny{}, fmt.Errorf("get %v from invalid", path)}
} else {
return &invalidAny{baseAny{}, fmt.Errorf("%v, get %v from invalid", any.err, path)}
}
}
2017-01-26 09:40:38 +02:00
func (any *invalidAny) Parse() *Iterator {
return nil
}
2017-01-26 09:44:10 +02:00
func (any *invalidAny) GetInterface() interface{} {
return nil
}