Go解析写死的json

func TestAliAfpAdapter_AskAd_Banner(t *testing.T) {
    apiData := getApiData()
    apiData.ApiInfo.ApiPositionSID = "63538378"
    apiData.AdRequst.AdWidth = 300
    apiData.AdRequst.AdHeigh = 250
    apiData.AdRequst.AdType = models.AD_TYPE_BANNER
    //adapter := &AliAfpAdapter{}
    //resp, err := adapter.AskAd(apiData)

    json := `JSON字符串`
    //fmt.Println(json)
    tresp := &aliafpResponse{}
    err := tresp.UnmarshalJSON([]byte(json))
    if err != nil {
        t.Error("unmarshal banner json error:" + err.Error())
    }

    respData, err := getAliafpResponse(tresp, apiData.AdRequst, apiData.AdidData, apiData.ApiInfo)
    if err != nil {
        t.Error("get banner response error:" + err.Error())
    }

    spew.Dump(respData)
    if respData.AdId == "" {
    }

}
原文地址:https://www.cnblogs.com/rxbook/p/6829900.html