File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 1
1
import Foundation
2
2
3
+ /// A configuration struct
4
+ public struct CacheJSONOptions {
5
+ /// Options used when creating Foundation objects from JSON data
6
+ public static var readingOptions : NSJSONReadingOptions = NSJSONReadingOptions ( )
7
+ /// Options for writing JSON data.
8
+ public static var writeOptions : NSJSONWritingOptions = NSJSONWritingOptions ( )
9
+ }
10
+
3
11
// MARK: - Cachable
4
12
5
13
/**
6
14
Implementation of Cachable protocol.
7
15
*/
16
+
8
17
extension JSON : Cachable {
9
18
10
19
public typealias CacheType = JSON
@@ -20,7 +29,7 @@ extension JSON: Cachable {
20
29
21
30
do {
22
31
let object = try NSJSONSerialization . JSONObjectWithData ( data,
23
- options: NSJSONReadingOptions ( ) )
32
+ options: CacheJSONOptions . readingOptions )
24
33
25
34
switch object {
26
35
case let dictionary as [ String : AnyObject ] :
@@ -42,6 +51,6 @@ extension JSON: Cachable {
42
51
*/
43
52
public func encode( ) -> NSData ? {
44
53
return try ? NSJSONSerialization . dataWithJSONObject ( object,
45
- options: NSJSONWritingOptions ( ) )
54
+ options: CacheJSONOptions . writeOptions )
46
55
}
47
56
}
You can’t perform that action at this time.
0 commit comments