优化自动生成json #3
@ -64,6 +64,7 @@ func (g *Generate) init() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
g.root.ValueType = valueType
|
g.root.ValueType = valueType
|
||||||
|
g.currentNode.ValueType = valueType
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if startIndex >= len(g.jsonDataByte) {
|
if startIndex >= len(g.jsonDataByte) {
|
||||||
@ -83,6 +84,16 @@ func (g *Generate) init() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println(jsonKey, valueType, jsonValue, startIndex)
|
fmt.Println(jsonKey, valueType, jsonValue, startIndex)
|
||||||
|
// 创建节点, 并挂在到树上
|
||||||
|
var newNode *Node
|
||||||
|
if g.currentNode.ValueType == ValueTypeArray || g.currentNode.ValueType == ValueTypeMap {
|
||||||
|
newNode = NewNode(jsonKey, jsonValue, valueType, g.currentNode)
|
||||||
|
g.currentParentNode = g.currentNode
|
||||||
|
g.currentParentNode.SonNodeList = append(g.currentParentNode.SonNodeList, newNode)
|
||||||
|
} else {
|
||||||
|
newNode = NewNode(jsonKey, jsonValue, valueType, g.currentParentNode)
|
||||||
|
}
|
||||||
|
g.currentNode = newNode
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user