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 } }
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 }
func (this *JsObject) Get(key interface{}) *JsObject { if !util.IsMap(this.value) { return nil } return (this.value.(map[interface{}]*JsObject))[key] }
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) }