我在swift代碼中成功使用parse JSON data但我想打印具有特定值的數據。眼下代碼vc.packages打印所有,但我只想打印誰是那些:過濾JSON數據並打印它
- 「TYPECODE」充滿「 validTo」有一個值,「stateCode」是有效的
如何在我的代碼中檢查並分別打印?
func unzipPackage() {
let vc = storyboard?.instantiateViewController(withIdentifier: "LoadingScreenController") as! LoadingScreenController
let popup = STPopupController(rootViewController: vc)
popup.style = .formSheet
popup.hidesCloseButton = false
popup.navigationBarHidden = true
popup.backgroundView = UIVisualEffectView(effect: UIBlurEffect(style: .dark))
popup.containerView.layer.cornerRadius = 4
popup.present(in: self, completion: {
DemosClient.sharedInstance.requestDataPackage()
.then { response -> Void in
vc.contentSizeInPopup = CGSize(width: 600, height: 800)
vc.landscapeContentSizeInPopup = CGSize(width: 600, height: 800)
vc.titles = (self.parseJSON(response: response))
print(vc.titles)
vc.packages = response["results"] as? [[String:Any]] ?? []
print(vc.packages)
}
.catch { error in
print(error)
}
vc.loadData()
vc.startTimer()
})
「validTo」有一個值嗎? –
@NiravD因爲它不是空的。例如在JSON解析中:validTo「:,它有一個空值,」validTo「:2017-05-11T07:57:07Z這個有一個值。 –
habed
你想從這個字典數組中獲得數組contentUrl嗎? –