1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 23:42:31 +03:00

Add a JSONConverter property to JSONConvertibles.

This commit is contained in:
Rob Rix 2015-09-21 16:27:45 -04:00
parent b5efc49129
commit 806ea1ea93

View File

@ -64,6 +64,12 @@ extension JSON: JSONConvertible {
}
}
extension JSONConvertible {
static var JSONConverter: Prism<Self, Doubt.JSON> {
return Prism(forward: { $0.JSON }, backward: { Self(JSON: $0) })
}
}
extension Prism where To : JSONConvertible {
public var number: Prism<From, Double> {
return self >>> Prism<To, Double>(forward: { $0.JSON.number }, backward: { To(JSON: .Number($0)) })