(un)marshalling json golang not working

前端 未结 2 738
一向
一向 2020-11-28 10:54

I\'m playing with Go and am stumped as to why json encode and decode don\'t work for me

I think i copied the examples almost verbatim, but the output says both marsh

2条回答
  •  被撕碎了的回忆
    2020-11-28 11:05

    Capitalize names of structure fields

    type testStruct struct {
        clip string `json:"clip"` // Wrong.  Lowercase - other packages can't access it
    }
    

    Change to:

    type testStruct struct {
        Clip string `json:"clip"`
    }
    

提交回复
热议问题