Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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