【发布时间】:2016-09-30 13:02:03
【问题描述】:
我的代码是这样的
import UIKit
import Alamofire
class ViewController: UIViewController {
var young = "https://jsonplaceholder.typicode.com/posts"
override func viewDidLoad() {
super.viewDidLoad()
callAlamo(url: young)
}
func callAlamo(url: String){
Alamofire.request(url).responseJSON { (response) in
let responseJSON = response.data
if responseJSON == nil{
print("response is empty")
}else{
print("Jon is \(responseJSON)")
self.parseJson(JSONData: responseJSON!)
}
}
}
func parseJson(JSONData: Data){
do{
let readableJSON = try JSONSerialization.jsonObject(with: JSONData, options: .mutableContainers)
for i in 0..<(readableJSON as AnyObject).count{
print(readableJSON[i] as String)
}
}catch{
print(error)
}
}
}
我需要这个 Json 中的每个数组元素。
【问题讨论】:
-
关于同样的错误信息有 > 20 个问题。请检查您的问题是否之前没有得到解答。
-
你能告诉我你正在获得表单服务的 JSON 吗?
标签: json swift swift3 alamofire