-3
獲得價值我有Dictionary
這樣,我得到「OutputResult」的價值,但我怎麼弄「的company_id」的價值,「部門」等。如何從字典swift3
if let convertedJsonIntoDict = try JSONSerialization.jsonObject(with: data!, options: []) as? NSDictionary
let firstNameValue = convertedJsonIntoDict["OutputResult"] as? String
print("OutputResult is :\(firstNameValue!)")
{
OutputResult = true;
msg = {
"company_id" = 1;
"department_id" = 6;
email = "[email protected]";
"employee_code" = 014;
"employee_id" = 131;
"employee_name" = "abc dsc";
"have_power" = 0;
ip = "";
"is_deleted" = 0;
lastactivity = "";
status = 1;
};
}
感謝您rply但錯誤在這行 **如果讓味精= convertedJsonIntoDict [ 「味精」],讓COMPANY_ID =味精[ 「COMPANY_ID」]作爲? Int, let department_id = msg [「department_id」] as? Int ** 其顯示類型「任何」沒有下標成員 – johnyDiOS
@johny忘記了添加'as? [字符串:任何]'檢查編輯的答案。 –
其工作我得到它,並感謝您的教學 – johnyDiOS