ppshein ppshein - 3 months ago 13
iOS Question

How to read data inside JSON object in swift

[
{
"id": "dcf8df3f8ce5963d7fa8",
"title": "MySurvey",
"description": "Guest Survey"
}
]


Above is json data response from api. I've read above json data with
SwiftyJSON
in my ios project as follow.

let swiftyJsonVar = JSON(responseData.result.value!)
print(swiftyJsonVar["title"])


I can't read and print above json data. Please let me know how to read above json data with
SwiftyJSON
.

Answer

The response is Array not Dictionary, try to access this

 let arr = swiftyJsonVar.arrayObject
 print(arr[0]["title"])
 print(arr[0]["id"])
 print(arr[0]["description"])