Skip to content

Instantly share code, notes, and snippets.

@foxicode
Created August 10, 2020 12:17
Show Gist options
  • Select an option

  • Save foxicode/64051beaa5a6cbadd99253a4c8146542 to your computer and use it in GitHub Desktop.

Select an option

Save foxicode/64051beaa5a6cbadd99253a4c8146542 to your computer and use it in GitHub Desktop.
Converting JSON String to Swift Array
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