JSONRawRepresentable
public protocol JSONRawRepresentable: JSONDeserializer, RawRepresentable
Protocol to auto-implement deserialization for RawRepresentable types.
Example:
The following enum automatically implements JSONDeserializer.
enum Lorem: String, JSONRawRepresentable {
case ipsum
case dolor
case sitAmet
}
-
deserialize(jsonObject:)Extension methodCasts the
jsonObjecttoRawValueand callsinit(rawValue:).Throws
JSONError.unexpectedTypeifjsonObjectcan’t be casted toRawValue.JSONError.invalidValueifinit(rawValue:)returnsnil.
Declaration
Swift
static func deserialize(jsonObject: JSONParsedObject) throws -> Self
View on GitHub
Install in Dash
JSONRawRepresentable Protocol Reference