1
This commit is contained in:
parent
f62a41fba7
commit
2a26b63c85
15
xobject.go
15
xobject.go
@ -15,6 +15,15 @@ type XObject struct {
|
||||
_val interface{}
|
||||
}
|
||||
|
||||
func NewXoFromJsonStr(jsonStr string) *XObject {
|
||||
p := new(XObject)
|
||||
if p.readFromJsonString(jsonStr) {
|
||||
return p
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (this *XObject) Size(key interface{}) int {
|
||||
if (this._type == XOT_ARRAY) {
|
||||
array := this._val.(*[]*XObject)
|
||||
@ -83,11 +92,7 @@ func (this *XObject) HasKey(key string) bool {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *XObject) ReadFromJsonFile(fileName string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (this *XObject) ReadFromJsonString(data string) bool {
|
||||
func (this *XObject) readFromJsonString(data string) bool {
|
||||
jsonType := JsonStrType(data)
|
||||
if jsonType == JSON_OBJECT {
|
||||
var rawJson map[string]interface{}
|
||||
|
24
xvalue.go
24
xvalue.go
@ -54,6 +54,30 @@ func (this *XValue) IsUndefined() bool {
|
||||
return this._type == XVT_UNDEFINED
|
||||
}
|
||||
|
||||
func (this *XValue) IsInt() bool {
|
||||
return this._type == XVT_INT
|
||||
}
|
||||
|
||||
func (this *XValue) IsFloat() bool {
|
||||
return this._type == XVT_INT
|
||||
}
|
||||
|
||||
func (this *XValue) IsNumber() bool {
|
||||
return this.IsInt() || this.IsFloat()
|
||||
}
|
||||
|
||||
func (this *XValue) IsString() bool {
|
||||
return this._type == XVT_STRING
|
||||
}
|
||||
|
||||
func (this *XValue) IsBytes() bool {
|
||||
return this._type == XVT_BYTES
|
||||
}
|
||||
|
||||
func (this *XValue) IsUserData() bool {
|
||||
return this._type == XVT_USERDATA
|
||||
}
|
||||
|
||||
func (this *XValue) SetUInt8(val uint8) *XValue {
|
||||
this.SetInt64(int64(val))
|
||||
return this
|
||||
|
Loading…
x
Reference in New Issue
Block a user