优化自动生成json #3

Merged
zhangdeman merged 24 commits from feature/tree into master 2023-05-05 16:10:39 +08:00
4629e31171 基础的JSON树构建
白茶清欢
2023-03-30 14:32:35 +08:00
Commit 14 of 24
Show all commits
+11
View File
@@ -64,6 +64,7 @@ func (g *Generate) init() error {
}
g.root.ValueType = valueType
g.currentNode.ValueType = valueType
for {
if startIndex >= len(g.jsonDataByte) {
@@ -83,6 +84,16 @@ func (g *Generate) init() error {
return err
}
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
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.