Swift解析服务器错误
我试图将测试对象保存到我的解析服务器,当我这样做时,我得到以下错误: 可选(错误域=NSCOCAERRORDOMAIN Code=3840“JSON文本未以数组或对象开头,允许未设置片段的选项。”UserInfo={NSDebugDescription=JSON文本未以数组或对象开头,允许未设置片段的选项。}) 我的解析配置如下所示:Swift解析服务器错误,swift,Swift,我试图将测试对象保存到我的解析服务器,当我这样做时,我得到以下错误: 可选(错误域=NSCOCAERRORDOMAIN Code=3840“JSON文本未以数组或对象开头,允许未设置片段的选项。”UserInfo={NSDebugDescription=JSON文本未以数组或对象开头,允许未设置片段的选项。}) 我的解析配置如下所示: let configuration = ParseClientConfiguration { $0.applicationId = "myAppID"
let configuration = ParseClientConfiguration {
$0.applicationId = "myAppID"
$0.clientKey = "myClientKey"
$0.server = "http://myPublicDNS"
}
Parse.initialize(with: configuration)
let test = PFObject(className:"test")
test["int"] = 1337
test["str"] = "Sean Plott"
test.saveInBackground {
(success: Bool, error: Error?) in
if (success) {
// The object has been saved.
print("succes")
} else {
// There was a problem, check error.description
print(error)
}
}
我的数据保存功能如下所示:
let configuration = ParseClientConfiguration {
$0.applicationId = "myAppID"
$0.clientKey = "myClientKey"
$0.server = "http://myPublicDNS"
}
Parse.initialize(with: configuration)
let test = PFObject(className:"test")
test["int"] = 1337
test["str"] = "Sean Plott"
test.saveInBackground {
(success: Bool, error: Error?) in
if (success) {
// The object has been saved.
print("succes")
} else {
// There was a problem, check error.description
print(error)
}
}
这是该类需要的属性的类屏幕
我如何修复这个恼人的错误?
提前感谢,,
Sander当我们没有将正确的数据发送到后端服务器或来自后端时,会出现此错误。
您必须向后端服务器检查您是否发送了他们所需的正确数据。您也可以在Postman上进行检查。谢谢您的回复,但我发现我使用了错误的服务器url。我想我发送了正确的数据,请参见问题中的屏幕截图。我也不知道你是说邮递员。感谢您的快速回复。在post man上,您可以检查后端服务的响应,您必须提供url和数据,它将返回respose,如果您发送的数据正确,则是后端错误。在postman或任何其他在线API检查器应用程序上检查它。