gpt4 book ai didi

.net - Swift - 错误的日期格式(JSON .NET)

转载 作者:行者123 更新时间:2023-11-30 13:46:49 35 4
gpt4 key购买 nike

我尝试在应用程序中使用 Alamofire 进行 API 调用,但收到一个奇怪的错误。

'There was an error deserializing the object of type Tucson.Geocaching.WCF.API.CreateTrackableLogRequestV1. DateTime content '\/Date(1452942271163+0500)\/' does not start with '\/Date(' and end with ')\/' as required for JSON.'

关于Website of the API它说日期格式必须是这样的: "\/Date(928174800000-0700)\/"

我的代码:

postTBLog("GSYCNP", text: "Test", date: "\\/Date(928174800000-0700)\\/", logType: 48)

func postTBLog (code: String, text: String, date: String, logType: Int) -> Bool {
if let apiKey = apiKey {
let url = "https://api.groundspeak.com/LiveV6/geocaching.svc/CreateTrackableLog"
let parameters:[String : AnyObject] = ["AccessToken":apiKey, "TrackingNumber":code, "UTCDateLogged": date, "Note":text, "LogType":logType]

Alamofire.request(.POST, url, parameters: parameters, encoding: .JSON).responseString { response in
print(response)
}



return true
} else {
return false
}
}

我已经尝试过不同的方法,但没有任何效果。如果您能帮助我,我将非常高兴,谢谢。

最佳答案

我将 "\\/Date(928174800000-0700)\\/" 转换为 "/Date(928174800000)/"

关于.net - Swift - 错误的日期格式(JSON .NET),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34826432/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com