2016-09-21 11 views
-2

このJSONをAPI呼び出しメソッドで解析します。すぐに3のJSONを解析する方法は?

{ 
    "Name": "sample string 1", 
    "About": "sample string 2", 
    "ImageUrl": "sample string 3", 
    "StartDate": "2016-09-21T13:07:25.4074934+00:00", 
    "IsPrivate": true, 
    "InvitedUser": [ 
    { 
     "Id": 1, 
     "Name": "sample string 2", 
     "PhoneNumber": "sample string 3" 
    }, 
    { 
     "Id": 1, 
     "Name": "sample string 2", 
     "PhoneNumber": "sample string 3" 
    } 
    ] 
} 

答えて

-1
func jsonParsing() 
    { 
     let path: NSString = NSBundle.mainBundle().pathForResource("jsondata", ofType: "json")! 
     let data : NSData = try! NSData(contentsOfFile: path as String, options: NSDataReadingOptions.DataReadingMapped) 

let dict: NSDictionary!=(try! NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers)) as! NSDictionary 

    dataDict = dict.valueForKey("main") as! NSDictionary 

     print("json data : ", dataDict) 

     self.tableview.reloadData() 


}