include graph root level in serialization
This commit is contained in:
parent
f26e9bd3e5
commit
b3ef7cd9aa
1 changed files with 6 additions and 3 deletions
|
|
@ -10,9 +10,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type SerializedGraph struct {
|
type SerializedGraph struct {
|
||||||
Root SerializedObject `json:"root"`
|
Root SerializedObject `json:"root"`
|
||||||
Edges []SerializedEdge `json:"edges"`
|
Edges []SerializedEdge `json:"edges"`
|
||||||
Objects []SerializedObject `json:"objects"`
|
Objects []SerializedObject `json:"objects"`
|
||||||
|
RootLevel int `json:"rootLevel"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SerializedObject map[string]interface{}
|
type SerializedObject map[string]interface{}
|
||||||
|
|
@ -30,6 +31,7 @@ func DeserializeGraph(bytes []byte, g *Graph) error {
|
||||||
convert(sg.Root, &root)
|
convert(sg.Root, &root)
|
||||||
g.Root = &root
|
g.Root = &root
|
||||||
root.Graph = g
|
root.Graph = g
|
||||||
|
g.RootLevel = sg.RootLevel
|
||||||
|
|
||||||
idToObj := make(map[string]*Object)
|
idToObj := make(map[string]*Object)
|
||||||
idToObj[""] = g.Root
|
idToObj[""] = g.Root
|
||||||
|
|
@ -91,6 +93,7 @@ func SerializeGraph(g *Graph) ([]byte, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
sg.Root = root
|
sg.Root = root
|
||||||
|
sg.RootLevel = g.RootLevel
|
||||||
|
|
||||||
var sobjects []SerializedObject
|
var sobjects []SerializedObject
|
||||||
for _, o := range g.Objects {
|
for _, o := range g.Objects {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue