Skip to content

Instantly share code, notes, and snippets.

View raditsan's full-sized avatar
🎯
Focusing

raditsan

🎯
Focusing
View GitHub Profile
@raditsan
raditsan / EncoderAndDecoder.swift
Created February 14, 2020 04:37
Decode from struct or class model to JSON String or Data
import UIKit
func newJSONDecoder() -> JSONDecoder {
let decoder = JSONDecoder()
if #available(iOS 10.0, OSX 10.12, tvOS 10.0, watchOS 3.0, *) {
decoder.dateDecodingStrategy = .iso8601
}
return decoder
}
func newJSONEncoder() -> JSONEncoder {