【发布时间】:2016-09-21 06:18:14
【问题描述】:
我的JSON回复是
{
code = 1;
document = (
{
Address1 = "<null>";
Address2 = "<null>";
City = "<null>";
CompanyID = 1;
CompanyName = Innohabit;
ContactNumber = "<null>";
Designation = "<null>";
DesignationID = 36;
DesignationName = dev;
Email = "uday.mishra@Gmail.com";
FCMRegistrationToken = "";
GCMRegistrationToken = "";
Gender = Male;
ID = 9;
IsActive = 1;
IsFirstLogin = 1;
LastLogin = "2016-09-21 05:45:33";
Name = "Uday Mishra";
Password = "";
ProfilePic = "";
RegisterationDate = "2016-03-04 07:42:42";
UserTwitter = "<null>";
Username = "uday.mishra@Gmail.com";
}
);
message = "Record found";
status = success;
}
并尝试使用Swifty Json 转换响应像这样
case .success:
print(response)
let jsonResponse = JSON(response.data)
print("JSON")
let jsonData = jsonResponse["document"]
print(jsonResponse)
print(jsonData[0])
但我没有得到想要的结果,输出是
{
code = 1;
document = (
{
Address1 = "<null>";
Address2 = "<null>";
City = "<null>";
CompanyID = 1;
CompanyName = Innohabit;
ContactNumber = "<null>";
Designation = "<null>";
DesignationID = 36;
DesignationName = dev;
Email = "uday.mishra@Gmail.com";
FCMRegistrationToken = "";
GCMRegistrationToken = "";
Gender = Male;
ID = 9;
IsActive = 1;
IsFirstLogin = 1;
LastLogin = "2016-09-21 05:45:33";
Name = "Uday Mishra";
Password = "";
ProfilePic = "";
RegisterationDate = "2016-03-04 07:42:42";
UserTwitter = "<null>";
Username = "uday.mishra@Gmail.com";
}
);
message = "Record found";
status = success;
}
JSON
unknown
null
您可以看到响应正在打印,但是 print(jsonResponse) 和 print(jsonData[0])
正在打印 Unknown 和 null 谁能帮助我如何将数据从DataRespose 正确序列化为JSON 格式
请提出任何替代方法,或者如果我做错了,请帮助我。
【问题讨论】:
-
pod 'SwiftyJSON', :git => 'github.com/appsailor/SwiftyJSON.git', :branch => 'swift3'
-
我在我的 pod 文件中使用相同的东西
-
仍然没有得到请帮助。
-
有没有其他选择。
-
你试过 SwiftJSON 吗?
标签: ios json xcode swifty-json