我想在下面这样做。如何使用“SwiftyJSON”将JSON.Element
转换为JSON
?
public func convert() -> String? {
let json :JSON = ["Animals" : ["dog","cat"], "Shop":"Tokyo"]
let animals = json["Animals"]
let repezentativeAnimal = animals.first
repezentativeAnimal!["Shop"] = json["Shop"] // Value of tuple type 'JSON.Element' (aka '(String, JSON)') has no member 'subscript'
// I want to return String below
// ["dog":"---", "Shop":"Tokyo"]
return repezentativeAnimal.rawString() // error : Value of type 'JSON.Element?' (aka 'Optional<(String, JSON)>') has no member 'rawString'
}
答案 0 :(得分:-1)
pod安装
pod'Alamofire-SwiftyJSON'
并导入您的VC
导入SwiftyJSON
导入Alamofire_SwiftyJSON