In golang I have two dimensional slice of pointers to struct, as shown in code below.
type point struct {
x int
y int
}
type cell struct {
point point
visited bool
walls walls
}
type walls struct {
n bool
e bool
s bool
w bool
}
type maze struct {
cells [][]*cell
solutionStack Stack
}
I would like to serialize cells slice into JSON. But as all the elements are pointers calling encode will give empty JSON. What would be the best way to serialize this slice.
One solution that comes to my mid is to create a local copy of this 2D slice ad replace all pointers with actual struct. It'll work but it is no