I'm looking for your help because I'm trying to convert my JSON to an Array of strings.
Actually I have my content like this :
var answers = JSON() {
didSet {
print(answers)
//radioTableView.items = ["ans1", "ans2", "ans3"]
radioTableView.reloadData()
}
}
My print give me an output like this (as a good JSON) :
[
"ans1",
"ans2",
"ans3"
]
My radioTableView.items is looking for an array of strings (to display my content nicely) but I can't find any way to convert my json as the right content that I'm looking for.
PS : I'm using SwiftyJSON.
Thank you for your help
你可以试试
radioTableView.items = answers.array!.map { $0.string! }
Additionally, if you would like to create structures from your JSON I found this handy site that will prepare the Swift Struct for you. Note: I do not work for the site or have any reason for linking it, aside from the fact that I find it to be an awesome tool.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.