Created
December 15, 2016 16:44
-
-
Save sgtmt/486e133b238651e0e7ae78b1d8d6493d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import SwiftyJSON | |
class ViewController: UIViewController { | |
var cJson:JSON = ["id":1,"name":"a","age":20,"sex":"m"] | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
} | |
@IBAction func Test_Btn(_ sender: AnyObject) { | |
let data = [ | |
"title":"title", | |
"a":["aa", | |
"bb", | |
"cc", | |
"dd", | |
"ee" | |
], | |
"b":["0", | |
"1", | |
"2", | |
"3", | |
"4" | |
], | |
"c":["1", | |
"2", | |
"3", | |
"4", | |
"5" | |
], | |
"d":["2", | |
"3", | |
"4", | |
"5", | |
"6" | |
], | |
"e":["1", | |
"2", | |
"3", | |
"4", | |
"5" | |
], | |
] as [String : Any] | |
] as [String : Any] | |
let json = JSON(data) | |
print(json["a"][0].stringValue) | |
print(json["b"][0].stringValue) | |
print(json["c"][0].stringValue) | |
print(json["d"][0].stringValue) | |
print(json["a"].count) | |
// → Optional(true) | |
} | |
// 取得したAPIデータの処理 | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment