{"title" : "saved users", "saved_users_list" :
[
{"username" : "Danny7", "name" : "Danny", "email" : "[email protected]"},
{"username" : "Ike2016", "name" : "Ike", "email" : "[email protected]"},
{"username" : "john202", "name" : "John", "email" : "[email protected]"},
{"username" : "ray_mundo", "name" : "Raymundo", "email" : "[email protected]"}
]
}
私はこのjsonをSwiftyJSONで解析しようとしていますが、動作していません。このjsonのサンプルをSwiftyJSONで解析するには?
Alamofire.request(.POST, url, parameters: parameters).validate().responseString { response in
switch response.result {
case .Success:
if let value = response.result.value {
value = JSON(value)
print(value)
}
}
プリント(値)上記のJSONを出力します。
json["saved_users_list"].count == 0
json["saved_users_list"][0]["username"] does not equal "Danny7"
json["title"] == null
は、ここで私は、データを得た方法です。
これまでのコードを共有できますか? (例えば、JSONの構文解析はどうですか?そして、あなたがここで共有しているもののように見えますか?) – smarx
ああ、私は文字列をjsonに正しく変換していないかもしれません。 – walton