簡體   English   中英

Swift-錯誤的日期格式(JSON .NET)

[英]Swift - Wrong date format (JSON .NET)

我試圖在我的應用中使用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.'

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)/"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM