2021-03-11 00:05:56 +08:00
|
|
|
// Package json...
|
|
|
|
//
|
|
|
|
// Description : json...
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<张德满>
|
|
|
|
//
|
|
|
|
// Date : 2021-03-10 11:44 下午
|
|
|
|
package json
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2021-03-14 23:31:08 +08:00
|
|
|
// TestJSON ...
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<张德满>
|
|
|
|
//
|
|
|
|
// Date : 10:58 下午 2021/3/14
|
2021-03-11 00:05:56 +08:00
|
|
|
func TestJSON(t *testing.T) {
|
|
|
|
tree := NewDynamicJSON()
|
2021-03-11 22:12:14 +08:00
|
|
|
fmt.Println(tree.extraSliceIndex("[200]"))
|
2021-03-11 00:05:56 +08:00
|
|
|
tree.SetValue("extra.height.value", 180)
|
2021-03-11 17:02:44 +08:00
|
|
|
tree.SetValue("extra.height.unit.use", "cm")
|
|
|
|
tree.SetValue("extra.height.unit.open", "1")
|
|
|
|
tree.SetValue("name", "zhangdeman")
|
|
|
|
tree.SetValue("good.name", "good")
|
|
|
|
tree.SetValue("work", "111")
|
|
|
|
tree.SetValue("good.price", "180")
|
|
|
|
tree.SetValue("good.unit", "$")
|
2021-03-12 23:08:48 +08:00
|
|
|
tree.SetValue("slice.[0].name", "zhang")
|
|
|
|
tree.SetValue("slice.[1].name", "de")
|
|
|
|
tree.SetValue("slice.[2].name", "man")
|
2021-03-12 23:28:28 +08:00
|
|
|
tree.SetValue("slice.[3]", "zhangdeman")
|
2021-03-11 17:02:44 +08:00
|
|
|
fmt.Println(tree.String())
|
2021-03-11 00:05:56 +08:00
|
|
|
}
|
2021-03-14 23:31:08 +08:00
|
|
|
|
|
|
|
// TestType 判断数据类型断言
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<张德满>
|
|
|
|
//
|
|
|
|
// Date : 10:59 下午 2021/3/14
|
|
|
|
func TestType(t *testing.T) {
|
|
|
|
|
|
|
|
}
|