我想像下面那样做。如何使用“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'
}
最佳答案
pods 安装
pod 'Alamofire-SwiftyJSON'
并导入你的VC
import SwiftyJSON
import Alamofire_SwiftyJSON
关于swift - 如何使用 `JSON.Element` 将 `JSON` 转换为 "SwiftyJSON"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48615806/