Beispiel #1
0
func verify(obj *JsObject) error {
	if !util.IsMap(obj.Value()) {
		return constant.NotMapError
	}
	id := obj.Get("ID").String()
	if id == "" {
		return constant.EmptyIDError
	} else {
		return nil
	}
}
Beispiel #2
0
func (this *JsObject) Len() int {
	if util.IsArray(this.value) {
		v := this.value.([]*JsObject)
		return len(v)
	}
	if util.IsMap(this.value) {
		v := this.value.(map[interface{}]*JsObject)
		return len(v)
	}
	return 0
}
Beispiel #3
0
func (this *JsObject) Get(key interface{}) *JsObject {
	if !util.IsMap(this.value) {
		return nil
	}
	return (this.value.(map[interface{}]*JsObject))[key]
}
Beispiel #4
0
func (this *JsObject) Set(key interface{}, value interface{}) {
	if !util.IsMap(this.value) {
		this.value = make(map[interface{}]*JsObject)
	}
	(this.value.(map[interface{}]*JsObject))[key] = pack(value)
}