File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ import Foundation
24
24
25
25
public struct JSON {
26
26
27
- private( set ) var object : AnyObject ?
27
+ private var object : AnyObject ?
28
28
29
29
public init ( ) {
30
30
self . object = nil
@@ -299,16 +299,14 @@ extension Dictionary {
299
299
300
300
extension JSON : RawRepresentable {
301
301
302
- enum JSONDataError : ErrorType {
303
- case ObjectMissing
304
- case InvalidJSONObject
302
+ enum DataError : ErrorType {
303
+ case MissingObject
304
+ case InvalidObject
305
305
}
306
306
307
307
public init ? ( rawValue: AnyObject ) {
308
308
guard NSJSONSerialization . isValidJSONObject ( rawValue) else {
309
- self . init ( )
310
-
311
- return
309
+ return nil
312
310
}
313
311
314
312
self . init ( rawValue)
@@ -318,13 +316,13 @@ extension JSON: RawRepresentable {
318
316
return self . object ?? NSNull ( )
319
317
}
320
318
321
- public func rawData( options: NSJSONWritingOptions = NSJSONWritingOptions ( rawValue : 0 ) ) throws -> NSData {
319
+ public func rawData( options: NSJSONWritingOptions = [ ] ) throws -> NSData {
322
320
guard let object = object else {
323
- throw JSONDataError . ObjectMissing
321
+ throw DataError . MissingObject
324
322
}
325
323
326
324
guard NSJSONSerialization . isValidJSONObject ( object) else {
327
- throw JSONDataError . InvalidJSONObject
325
+ throw DataError . InvalidObject
328
326
}
329
327
330
328
return try NSJSONSerialization . dataWithJSONObject ( object, options: options)
You can’t perform that action at this time.
0 commit comments