diff --git a/Sources/Cache/JSON.swift b/Sources/Cache/JSON.swift index ef92057..36a499a 100644 --- a/Sources/Cache/JSON.swift +++ b/Sources/Cache/JSON.swift @@ -5,15 +5,19 @@ import c To create a `JSON` object, pass a `Data` object that contains JSON data to the `init(data:)` method. You can then use the `get(_:)` or `resolve(_:)` method to extract individual values from the JSON data. - let jsonData = "{\"name\": \"John Doe\", \"age\": 42}".data(using: .utf8)! - let json = JSON(data: jsonData) +```swift +let jsonData = "{\"name\": \"John Doe\", \"age\": 42}".data(using: .utf8)! +let json = JSON(data: jsonData) - let name: String = try json.resolve(.name) - let age: Int = try json.resolve(.age) +let name: String = try json.resolve(.name) +let age: Int = try json.resolve(.age) +``` You can also use the `set(value:forKey:)` method to update the values in the JSON object, and the `get(_:)` or `resolve(_:)` method to retrieve the values from the object. - json.set(value: "Jane Doe", forKey: .name) - let newName: String = try json.resolve(.name) +```swift +json.set(value: "Jane Doe", forKey: .name) +let newName: String = try json.resolve(.name) +``` */ public typealias JSON = c.JSON