class JSONNull: Codable, Hashable {
public static func == (lhs: JSONNull, rhs: JSONNull) -> Bool {
return true
}
public var hashValue: Int {
return 0
}
public init() {}
public required init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
if !container.decodeNil() {
throw DecodingError.typeMismatch(JSONNull.self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Wrong type for JSONNull"))
}
}
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
try container.encodeNil()
}
}
반응형
'iOS > swift' 카테고리의 다른 글
pasteboard에 이미지 데이터 넣기 (0) | 2021.02.22 |
---|---|
한글 자모의 유니코드에 대한 글 (0) | 2021.02.03 |
[Swift5] Struct -> JSON -> String, Dictionary (0) | 2020.12.31 |
문자열 내부의 단어를 찾는 방법 (0) | 2020.11.25 |
LAError Code (구글 번역기) (0) | 2020.09.16 |