I have a json file (themes / snow / theme.json)
{ Name:'snow', Bgimage:'background.jpg', Width:600, Height:400, Itemrotation:'20,40', Text:{ Fontsize:12, Color:'#ff00ff', Fontfamily:'verdana', Bottommargin:20 }, Decoration:[ { Path:'abc.jpg', X:2, Y:4, Rotation:0 }, { Path:'def.png', X:4, Y:22, Rotation:10 } ] }
And I have a file that parses json data
package main import ( "fmt" "os" "encoding/json" "io/ioutil" "log" ) const themeDirectory = "themes" const themeJsonFile = "theme.json" type TextInfo struct { Fontsize int Color string Fontfamily string Bottommargin int } type DecoInfo struct { Path string X int Y int Rotation int } type ThemeInfo struct { Name string Bgimage string Width int Height int Itemrotation string Text textInfo Decoration []decoInfo } func main() { var tinfo = parseTheme("snow")
You can see that I have 2 lines to the end
fmt.Println(t)
I'm not sure why it prints
{ 0 0 {0 0} []}
I expect it to return the themeInfo to me in a useful way so that I can use it for further processing. What am I doing wrong here?
source share