Skip to content

Commit

Permalink
Merge pull request #2201 from alixander/serialize-data
Browse files Browse the repository at this point in the history
serialize data var
  • Loading branch information
alixander authored Nov 7, 2024
2 parents 426c3e9 + f5894e2 commit 2f3721c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions d2graph/serde.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import (
)

type SerializedGraph struct {
Root SerializedObject `json:"root"`
Edges []SerializedEdge `json:"edges"`
Objects []SerializedObject `json:"objects"`
RootLevel int `json:"rootLevel"`
Root SerializedObject `json:"root"`
Edges []SerializedEdge `json:"edges"`
Objects []SerializedObject `json:"objects"`
RootLevel int `json:"rootLevel"`
Data map[string]interface{} `json:"data,omitempty"`
}

type SerializedObject map[string]interface{}
Expand All @@ -27,6 +28,7 @@ func DeserializeGraph(bytes []byte, g *Graph) error {
return err
}

g.Data = sg.Data
var root Object
Convert(sg.Root, &root)
g.Root = &root
Expand Down Expand Up @@ -95,6 +97,7 @@ func SerializeGraph(g *Graph) ([]byte, error) {
}
sg.Root = root
sg.RootLevel = g.RootLevel
sg.Data = g.Data

var sobjects []SerializedObject
for _, o := range g.Objects {
Expand Down

0 comments on commit 2f3721c

Please sign in to comment.