Private Sub TreeFromJson (json As String)
Tree.Clear
Dim children As List = json.As(JSON).ToList
TreeFromJsonImpl(Tree.Root, children)
End Sub
Private Sub TreeFromJsonImpl (ParentTreeNode As CLVTreeItem, ParentList As List)
For Each m As Map In ParentList
Dim ti As CLVTreeItem = Tree.AddItem(ParentTreeNode, m.Get("text"), Null, "")
If m.ContainsKey("children") Then
TreeFromJsonImpl(ti, m.Get("children"))
End If
Next
End Sub
Private Sub TreeToJson As String
Dim l As List
l.Initialize
TreeToJsonImpl(Tree.Root, l)
Return l.As(JSON).ToString
End Sub
Private Sub TreeToJsonImpl (ParentTreeNode As CLVTreeItem, ParentList As List)
For Each child As CLVTreeItem In ParentTreeNode.Children
Dim m As Map = CreateMap("text": child.Text)
ParentList.Add(m)
If child.Children.IsInitialized And child.Children.Size > 0 Then
Dim children As List
children.Initialize
m.Put("children", children)
TreeToJsonImpl(child, children)
End If
Next
End Sub