1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 08:25:19 +03:00

JSON is public.

This commit is contained in:
Rob Rix 2015-09-21 15:23:16 -04:00
parent d82acf8b9f
commit a787679652

View File

@ -1,4 +1,4 @@
enum JSON { public enum JSON {
case Number(Double) case Number(Double)
case Boolean(Bool) case Boolean(Bool)
case String(Swift.String) case String(Swift.String)
@ -6,43 +6,43 @@ enum JSON {
case Dictionary([Swift.String:Doubt.JSON]) case Dictionary([Swift.String:Doubt.JSON])
case Null case Null
var number: Double? { public var number: Double? {
if case let .Number(d) = self { return d } if case let .Number(d) = self { return d }
return nil return nil
} }
var boolean: Bool? { public var boolean: Bool? {
if case let .Boolean(b) = self { return b } if case let .Boolean(b) = self { return b }
return nil return nil
} }
var string: Swift.String? { public var string: Swift.String? {
if case let .String(s) = self { return s } if case let .String(s) = self { return s }
return nil return nil
} }
var array: [Doubt.JSON]? { public var array: [Doubt.JSON]? {
if case let .Array(a) = self { return a } if case let .Array(a) = self { return a }
return nil return nil
} }
var dictionary: [Swift.String:Doubt.JSON]? { public var dictionary: [Swift.String:Doubt.JSON]? {
if case let .Dictionary(d) = self { return d } if case let .Dictionary(d) = self { return d }
return nil return nil
} }
var isNull: Bool { public var isNull: Bool {
if case .Null = self { return true } if case .Null = self { return true }
return false return false
} }
static let JSON: Prism<AnyObject, Doubt.JSON> = Prism(forward: toJSON, backward: toAnyObject) public static let JSON: Prism<AnyObject, Doubt.JSON> = Prism(forward: toJSON, backward: toAnyObject)
static let number: Prism<Doubt.JSON, Double> = Prism(forward: { $0.number }, backward: { .Number($0) }) public static let number: Prism<Doubt.JSON, Double> = Prism(forward: { $0.number }, backward: { .Number($0) })
static let boolean: Prism<Doubt.JSON, Bool> = Prism(forward: { $0.boolean }, backward: { .Boolean($0) }) public static let boolean: Prism<Doubt.JSON, Bool> = Prism(forward: { $0.boolean }, backward: { .Boolean($0) })
static let string: Prism<Doubt.JSON, Swift.String> = Prism(forward: { $0.string }, backward: { .String($0) }) public static let string: Prism<Doubt.JSON, Swift.String> = Prism(forward: { $0.string }, backward: { .String($0) })
static let array: Prism<Doubt.JSON, [Doubt.JSON]> = Prism(forward: { $0.array }, backward: { .Array($0) }) public static let array: Prism<Doubt.JSON, [Doubt.JSON]> = Prism(forward: { $0.array }, backward: { .Array($0) })
static let dictionary: Prism<Doubt.JSON, [Swift.String:Doubt.JSON]> = Prism(forward: { $0.dictionary }, backward: { .Dictionary($0) }) public static let dictionary: Prism<Doubt.JSON, [Swift.String:Doubt.JSON]> = Prism(forward: { $0.dictionary }, backward: { .Dictionary($0) })
} }
private func toJSON(object: AnyObject) -> JSON? { private func toJSON(object: AnyObject) -> JSON? {