Ios 如何在Swift中访问JSON响应中的特定数据

Ios 如何在Swift中访问JSON响应中的特定数据,ios,json,swift,parsing,networking,Ios,Json,Swift,Parsing,Networking,当我运行swift程序时,我有这个JSON响应 { "success": true, "info": "Groups", "data": { "groups": "[{\"id\":1,\"name\":\"test\",\"user_id\":1,\"active\":null,\"public\":true,\"image_file_name\":null,\"image_content_type\":null,\"image_file_size\":null,\"image_upd

当我运行swift程序时,我有这个JSON响应

{
"success": true,
"info": "Groups",
"data": {
    "groups": "[{\"id\":1,\"name\":\"test\",\"user_id\":1,\"active\":null,\"public\":true,\"image_file_name\":null,\"image_content_type\":null,\"image_file_size\":null,\"image_updated_at\":null,\"created_at\":\"2017-10-15T20:40:13.671+01:00\",\"updated_at\":\"2017-10-15T20:40:13.671+01:00\",\"hashtag\":null},{\"id\":4,\"name\":\"test_again\",\"user_id\":1,\"active\":null,\"public\":false,\"image_file_name\":null,\"image_content_type\":null,\"image_file_size\":null,\"image_updated_at\":null,\"created_at\":\"2018-01-16T18:17:06.575+00:00\",\"updated_at\":\"2018-01-16T18:17:06.575+00:00\",\"hashtag\":null}]"
}
但是,我希望访问组中包含的信息,特别是组的id和名称。有什么简单的方法可以做到这一点吗

let dic  = response["data"] as! [String:Any]

let groups = dic["groups"] as! String
然后使用jsonSerialization解析组


组对应于字符串,而不是JSON数组。因为它用引号括起来,提取字符串,然后将其解析为数组。这正是我需要知道的,谢谢。如果你控制后端或服务,或者可以联系负责人,那么你就知道了;请他们不要将其作为字符串发送。它打破了所有的惯例。我确实可以访问后端,但我不是自己写的,它在rails中,所以我不知道如何更改它。如果我要更改它,我会将字符串中的所有内容作为嵌套响应发送吗?是的,这是正确的。
let id  = data["id"]