提交 01f88695 编写于 作者: yanghye's avatar yanghye

upgrade-dev v2.3.47

上级 99271190
......@@ -26,7 +26,7 @@ import (
const (
null = "null"
undefined = "Undefined"
undefined = "undefined"
)
var (
......
......@@ -55,7 +55,8 @@ func (m *bindRenderProcess) webKitMakeBind() {
for item := fields.Front(); item != nil; item = item.Next() {
jsv := bind.ElementToJSValue(item)
names := strings.Split(jsv.Name(), ".")
fmt.Println("object ElementToJSValue Object:", jsv.Name())
fmt.Println("object ElementToJSValue Object:", jsv.Name(), jsv.Type())
//fmt.Println("object:", object.ToJSONString())
if len(names) == 1 {
if jsv.IsObject() {
object.Set(jsv.Name(), json.NewJSONObject(nil))
......@@ -65,29 +66,30 @@ func (m *bindRenderProcess) webKitMakeBind() {
object.Set(jsv.Name(), jsv.JSON().Data())
}
} else {
//for _, name := range jsv.Name()[:len(jsv.Name())-1] {
//
//}
//if jsv.IsObject() || jsv.IsArray() {
// fmt.Println("object ElementToJSValue Object:", strings.Join(jsv.Name(), "."), jsv.JSON().ToJSONString())
// for _, name := range jsv.Name() {
// if pObject := object.GetByKey(name); pObject != nil {
// if jsv.IsObject() {
// object.Set(strings.Join(jsv.Name(), "."), json.NewJSONObject(nil))
// } else if jsv.IsArray() {
// object.Set(strings.Join(jsv.Name(), "."), json.NewJSONArray(nil))
// }
// }
// }
// if jsv.IsObject() {
// object.Set(strings.Join(jsv.Name(), "."), json.NewJSONObject(nil))
// } else if jsv.IsArray() {
// object.Set(strings.Join(jsv.Name(), "."), json.NewJSONArray(nil))
// }
//} else {
// fmt.Println("object ElementToJSValue:", strings.Join(jsv.Name(), "."), jsv.JSON().ToJSONString())
// //object.Set(strings.Join(jsv.Name(), "."), jsv.JSON().Data())
//}
name := names[len(names)-1]
var pObject = object
for i := 0; i < len(names)-1; i++ {
pObject = pObject.GetByKey(names[i])
}
if jsv.IsObject() {
if pObject.IsArray() {
pObject.JSONArray().Add(json.NewJSONObject(nil))
} else {
pObject.Set(name, json.NewJSONObject(nil))
}
} else if jsv.IsArray() {
if pObject.IsObject() {
pObject.Set(name, json.NewJSONArray(nil))
} else {
pObject.JSONArray().Add(json.NewJSONArray(nil))
}
} else {
if pObject.IsObject() {
pObject.Set(name, nil)
} else if pObject.IsArray() {
pObject.JSONArray().Add(nil)
}
}
}
}
......
......@@ -44,7 +44,7 @@ func main() {
fmt.Println("nullKey", nullKey.Value())
undefinedKey := bind.NewUndefined("undefinedKey")
fmt.Println("undefinedKey", undefinedKey.Value(), undefinedKey.IsUndefined())
funcKey := bind.NewFunction("funcKey", func() {
funcKey := bind.NewFunction("funcKey", func(i1 int) {
})
fmt.Println("funcKey", funcKey)
......@@ -79,7 +79,14 @@ func main() {
//Key4: 555.3,
//Key5: true,
//Key6: &objectDemo1{},
Key7: objectDemo2{Key4: &objectDemo1{}},
Key7: objectDemo2{
Key4: &objectDemo1{},
},
Key8: make([]string, 0),
Key9: make([]objectDemo2, 0),
Key10: &objectDemo2{
Key5: make([]*objectDemo1, 0),
},
}
bind.NewObject(testObj)
bind.NewArray("arrayKey", "字符串", 100001, 22222.333, true, testObj)
......
......@@ -260,6 +260,7 @@ func (m *JsonData) Add(value ...any) {
}
m.V = append(m.V.([]any), tmp...)
m.S += len(value)
m.modifyParentValue()
}
}
......@@ -281,6 +282,7 @@ func (m *JsonData) SetByIndex(index int, value any) {
default:
m.V.([]any)[index] = value
}
m.modifyParentValue()
}
}
......@@ -289,6 +291,7 @@ func (m *JsonData) RemoveByIndex(index int) {
v := m.V.([]any)
m.V = append(v[:index], v[index+1:]...)
m.S--
m.modifyParentValue()
}
}
......@@ -534,6 +537,7 @@ func (m *JsonData) RemoveByKey(key string) {
if _, ok := m.V.(map[string]any)[key]; ok {
delete(m.V.(map[string]any), key)
m.S--
m.modifyParentValue()
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册