@@ -11,7 +11,7 @@ type fieldNodeTree struct {
1111 IsAnonymous bool //是否是匿名结构体,内嵌结构体,需要把所有字段展开
1212 IsNil bool //该字段值是否为nil
1313 ParentNode * fieldNodeTree //父节点指针,根节点为nil,
14- ChildNodes []* fieldNodeTree //如果是struct则保存所有字段名和值的指针,如果是切片就保存切片的所有值
14+ Children []* fieldNodeTree //如果是struct则保存所有字段名和值的指针,如果是切片就保存切片的所有值
1515}
1616
1717func (t * fieldNodeTree ) GetValue () (val interface {}, ok bool ) {
@@ -22,21 +22,21 @@ func (t *fieldNodeTree) GetValue() (val interface{}, ok bool) {
2222 if t .IsNil {
2323 return nil , true
2424 }
25- if t .ChildNodes == nil {
25+ if t .Children == nil {
2626 return t .Val , true
2727 }
2828 if t .IsSlice { //为切片和数组时候key为空
29- slices := make ([]interface {}, 0 , len (t .ChildNodes ))
30- for i := 0 ; i < len (t .ChildNodes ); i ++ {
31- value , ok0 := t .ChildNodes [i ].GetValue ()
29+ slices := make ([]interface {}, 0 , len (t .Children ))
30+ for i := 0 ; i < len (t .Children ); i ++ {
31+ value , ok0 := t .Children [i ].GetValue ()
3232 if ok0 {
3333 slices = append (slices , value )
3434 }
3535 }
3636 return slices , true
3737 }
3838 maps := make (map [string ]interface {})
39- for _ , v := range t .ChildNodes {
39+ for _ , v := range t .Children {
4040 value , ok1 := v .GetValue ()
4141 if ok1 {
4242 maps [v .Key ] = value
@@ -47,18 +47,18 @@ func (t *fieldNodeTree) GetValue() (val interface{}, ok bool) {
4747
4848func (t * fieldNodeTree ) Map () map [string ]interface {} {
4949 maps := make (map [string ]interface {})
50- for _ , v := range t .ChildNodes {
51- value , ok := ( * v ) .GetValue ()
50+ for _ , v := range t .Children {
51+ value , ok := v .GetValue ()
5252 if ok {
53- maps [( * v ) .Key ] = value
53+ maps [v .Key ] = value
5454 }
5555 }
5656 return maps
5757}
5858func (t * fieldNodeTree ) Slice () interface {} {
59- slices := make ([]interface {}, 0 , len (t .ChildNodes ))
60- for i := 0 ; i < len (t .ChildNodes ); i ++ {
61- v , ok := t .ChildNodes [i ].GetValue ()
59+ slices := make ([]interface {}, 0 , len (t .Children ))
60+ for i := 0 ; i < len (t .Children ); i ++ {
61+ v , ok := t .Children [i ].GetValue ()
6262 if ok {
6363 slices = append (slices , v )
6464 }
@@ -75,10 +75,10 @@ func (t *fieldNodeTree) Marshal() interface{} {
7575}
7676
7777func (t * fieldNodeTree ) AddChild (tree * fieldNodeTree ) * fieldNodeTree {
78- if t .ChildNodes == nil {
79- t .ChildNodes = make ([]* fieldNodeTree , 0 , 3 )
78+ if t .Children == nil {
79+ t .Children = make ([]* fieldNodeTree , 0 , 3 )
8080 }
81- t .ChildNodes = append (t .ChildNodes , tree )
81+ t .Children = append (t .Children , tree )
8282 return t
8383}
8484
0 commit comments