Bouke / HAP

Swift implementation of the Homekit Accessory Protocol
https://boukehaarsma.nl/HAP/
MIT License
364 stars 50 forks source link

Question: Why JSONSerializable vs Codable? #87

Closed KyleLeneau closed 5 years ago

KyleLeneau commented 5 years ago

How come you have a seemingly custom JSONSerializable interface over using Codable? Is it due to the type support and what have you found as a limitation:

extension Array: JSONValueType { }
extension Dictionary: JSONValueType { }
extension String: JSONValueType { }
extension Bool: JSONValueType { }
extension Int: JSONValueType { }
extension UInt8: JSONValueType { }
extension UInt16: JSONValueType { }
extension UInt32: JSONValueType { }
extension Float: JSONValueType { }
extension Double: JSONValueType { }
extension NSNull: JSONValueType { }
Bouke commented 5 years ago

Codable is a language feature introduced some time after this project came about. I've looked into using Codable, but I would need to rewrite substantial amounts of code for no direct benefit. Second; the JSON parsing on Linux (SwiftFoundation) used to have some rough edges that prevented me from using some stdlib functionality. That said, the situation probably has improved over time and some of these constraints might no longer hold.