// // FileTools.swift // SHECommunity // // Created by Lin on 2024/12/9. // import UIKit class FileTools: NSObject { /// 读取json文件 static func readJSONFromFile(fileName: String) -> [String: Any]? { if let fileURL = Bundle.main.url(forResource: fileName, withExtension: "json") { do { let jsonData = try Data(contentsOf: fileURL) let jsonObject = try JSONSerialization.jsonObject(with: jsonData, options: []) if let jsonDictionary = jsonObject as? [String: Any] { // 处理得到的 JSON 字典 return jsonDictionary } } catch { print("读取 JSON 文件发生错误: \(error)") } } return nil } }