How to convert JSON string to struct

前端 未结 1 1244
执念已碎
执念已碎 2021-01-19 19:44

I have start working in golang, I am trying to parse JSON string to struct but its not working.

JSON String:

dailies\":[{\"us

1条回答
  •  说谎
    说谎 (楼主)
    2021-01-19 20:09

    The fields in pingDataFormat need to be exported (start with a capital letter)

    type pingDataFormat struct {
        UserAccessToken          string `json:"userAccessToken"`
        UploadStartTimeInSeconds int    `json:"uploadStartTimeInSeconds"`
        UploadEndTimeInSeconds   int    `json:"uploadEndTimeInSeconds"`
        CallbackURL              string `json:"callbackURL"`
    }
    

    That should solve your problem

    https://play.golang.org/p/Z3yszFl01L

    0 讨论(0)
提交回复
热议问题