swift4 txt中json取出

guard
let url = Bundle.main.url(forResource: "source/AllCountry/zh_Hans_CNCountry", withExtension: "txt"),
let data = Data(contentsOf: url) else {
return
}

do {
let info = try JSONSerialization.jsonObject(with: data as Data, options: .mutableContainers)

        if
            let data = info as? [AnyHashable: [[String: String]]],
            let array = data["data"] {
       
            print(array)
        }
        
        //print(info)
        
    } catch {
        print(error)
    }

你可能感兴趣的:(swift4 txt中json取出)