func (this *JsObject) Append(value interface{}) { if !util.IsArray(this.value) { return } v := this.value.([]*JsObject) v = append(v, pack(value)) this.value = v }
func (this *JsObject) GetByIndex(index int) *JsObject { if !util.IsArray(this.value) { return nil } v := this.value.([]*JsObject) if l := len(v); l <= index { return nil } return v[index] }
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) SetByIndex(index int, value interface{}) { if !util.IsArray(this.value) { array := make([]*JsObject, index+1) array[index] = pack(value) this.value = array return } else { v := this.value.([]*JsObject) if l := len(v); l <= index { sliceToAppend := make([]*JsObject, index-l+1) this.value = append(v, sliceToAppend...) v = this.value.([]*JsObject) } v[index] = pack(value) } }