Created
August 7, 2020 20:41
-
-
Save IanKeen/46c7ca24708a1a56c75d4f71299aaad5 to your computer and use it in GitHub Desktop.
Quick and dirty way to get a keypath from Decodable error
This file contains 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
extension Array where Element: CodingKey { | |
var keyPath: String { | |
return map { $0.intValue == nil ? $0.stringValue : "[\($0.intValue!)]" } | |
.joined(separator: ".") | |
.replacingOccurrences(of: ".[", with: "[") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment