Ios 如何在JSON中获取字符串值

Ios 如何在JSON中获取字符串值,ios,json,swift,rest,get,Ios,Json,Swift,Rest,Get,这是我的JSON { "StatusResponse": { "StatusCode": "000" "StatusDescription": "Operation Success(000)" "DebugDescription": "OperationSuccess" }- "memId": "3e369fec-a9c5-418b-a950-0647f7e15d7c" "token": null

这是我的JSON

{
    "StatusResponse": 
    {
        "StatusCode": "000"
        "StatusDescription": "Operation Success(000)"
        "DebugDescription": "OperationSuccess"
    }-
    "memId": "3e369fec-a9c5-418b-a950-0647f7e15d7c"
    "token": null
    "isAdmin": false
    "isTeacher": false
    "isParent": true
    "kinderId": null
}
我可以使用Http Get方法检索
StatusResponse
字典

RestApiManager.sharedInstance.makeGetRequest("myURL", onCompletion: {json in
        for result in json["StatusResponse"].dictionaryValue
        {
            print(result)
        }
    })
在这里,我的结果输出如下

("DebugDescription", OperationSuccess)
("StatusDescription", Operation Success(000))
("StatusCode", 000)

我想问的问题是如何通过使用FOR EACH循环在我的代码中获取StatusCode的stringValue?

使用这个:

if let statusCode = json["StatusResponse"]["StatusCode"].string {
    println(statusCode)
}

OP,您正在使用快速json,在您的问题中提及它将是一件好事…json[“StatusResponse”][“StatusCode”]?我的答案适合您。勾选并投票给我的答案。这对其他人很有帮助。@Ramest\T如果我想用于每个循环,该怎么办?它将打印完整的字典。如果您希望从响应中获得特定值。使用yourResponseDict[“requiredKey”]。我以前也这样做过,但不幸的是它不起作用…错误在这里=>Type'(String,JSON)'没有下标成员Type'(String,JSON)'没有下标成员…这是Xcode显示的错误
   let statusCodeValue = json["StatusResponse"]["StatusCode"].stringValue
   print("The ststusCodeValue is - \(stausCodeValue)")

   let tatusDescriptionValue = json["StatusResponse"]["StatusDescription"].stringValue
   print("The statusDescriptionValue is - \(statusDescriptionValue)")

   let debugDescriptionValue = json["StatusResponse"]["DebugDescription"].stringValue
   print("The debugDescriptionValue is - \(DebugDescriptionValue)")