Skip to content

Instantly share code, notes, and snippets.

@sgtmt
Created December 15, 2016 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgtmt/486e133b238651e0e7ae78b1d8d6493d to your computer and use it in GitHub Desktop.
Save sgtmt/486e133b238651e0e7ae78b1d8d6493d to your computer and use it in GitHub Desktop.
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