func graphToJSON(g system.CoreGraph) ([]byte, error) { var vertices []interface{} for _, v := range g.VerticesWith(q.Qbv(system.VTypeNone)) { vertices = append(vertices, v.Flat()) } // TODO use something that lets us write to a reusable byte buffer instead return json.Marshal(struct { Id uint64 `json:"id"` Vertices []interface{} `json:"vertices"` }{ Id: g.MsgID(), Vertices: vertices, }) }