Created
August 10, 2020 12:17
-
-
Save foxicode/64051beaa5a6cbadd99253a4c8146542 to your computer and use it in GitHub Desktop.
Converting JSON String to Swift Array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| extension String { | |
| var asArray: [Any]? { | |
| guard let data = self.data(using: .utf8) else { return nil } | |
| return try? JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [Any] | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment