How to decode json into structs

后端 未结 3 1215
既然无缘
既然无缘 2021-02-08 00:21

I\'m trying to decode some json in Go but some fields don\'t get decoded. See the code running in browser here:

What am I doing wrong?

I need only the MX reco

3条回答
  •  梦如初夏
    2021-02-08 01:18

    The encoding/json package can only decode into exported struct fields. Your Data.mxRecords member is not exported, so it is ignored when decoding. If you rename it to use a capital letter, the JSON package will notice it.

    You will need to do the same thing for all the members of your MxRecords type.

提交回复
热议问题