| ... | ... | @@ -219,5 +219,25 @@ Task { |
|
|
|
```
|
|
|
|
|
|
|
|
### JSON
|
|
|
|
```swift
|
|
|
|
// パースするJSON文字列
|
|
|
|
// 文字列ではないのに、数値が文字列で入っている
|
|
|
|
let jsonString: String = """
|
|
|
|
{"id":"1", "name":"Suzuki", "point":"20.5"}
|
|
|
|
"""
|
|
|
|
// JSON文字列をData型に変換
|
|
|
|
let personalData: Data = jsonString.data(using: String.Encoding.utf8)!
|
|
|
|
|
|
|
|
do {
|
|
|
|
let items = try GngJson.convertToDictionary(json: personalData)
|
|
|
|
let id = GngJson.parseInt(from: items, key: "id") // Int型として解析
|
|
|
|
let name = items["name"] as! String
|
|
|
|
let point = GngJson.parseFloat(from: items, key: "point") // Float型として解析
|
|
|
|
} catch {
|
|
|
|
print(error)
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Utils
|
|
|
|
|
|
|
|
## Utils |
|
|
\ No newline at end of file |
|
|
|
### Appバーっジョン |