amical/packages/native-helpers/swift-helper/Sources/SwiftHelper/JSONHelpers.swift
Haritabh 95cb9f11f8
chore: add swift helper (#11)
* chore: add swift helper

* chore: separate out types into types pkg

* chore: only build apps/www for now

* chore: don't build swift helper as part of pnpm i
2025-05-24 05:30:25 +05:30

20 lines
No EOL
624 B
Swift

import Foundation
// Shared JSON helper functions to avoid redeclaration errors across generated files
enum JSONHelpers {
static 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
}
static func newJSONEncoder() -> JSONEncoder {
let encoder = JSONEncoder()
if #available(iOS 10.0, OSX 10.12, tvOS 10.0, watchOS 3.0, *) {
encoder.dateEncodingStrategy = .iso8601
}
return encoder
}
}