iOS/설명
[iOS] JSON String을 Dictionary로 변환
Sky Titan
2022. 1. 8. 16:16
728x90
extension String {
public func convertToDictionary() -> [String: Any]? {
if let data = self.data(using: .utf8) {
do {
return try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
} catch {
print(error.localizedDescription)
}
}
return nil
}
}728x90