//Your json should be like this
{"Hours_Of_Operation" : [{"daysofweek":"1", "open_time":"11:00:00", "close_time":"00:00:00"},{"daysofweek":"2", "open_time":"11:00:00", "close_time":"00:00:00"},{"daysofweek":"3", "open_time":"11:00:00", "close_time":"00:00:00"},{"daysofweek":"4", "open_time":"11:00:00", "close_time":"02:00:00"},{"daysofweek":"5", "open_time":"11:00:00", "close_time":"02:00:00"},{"daysofweek":"6", "open_time":"10:00:00", "close_time":"02:00:00"},{"daysofweek":"7", "open_time":"10:00:00", "close_time":"00:00:00"}]}
//Using this json you can parse data
let arrayHoursOfOperation = yourJsonDictionary.objectForKey("Hours_Of_Operation") as! NSArray
您可以使用ComponentSeparatedByString
獲得期望的結果。您甚至需要根據您的要求修改此代碼。
NSString *str = @"{"daysofweek":"1", "open_time":"11:00:00", "close_time":"00:00:00"},{"daysofweek":"2", "open_time":"11:00:00", "close_time":"00:00:00"},{"daysofweek":"3", "open_time":"11:00:00", "close_time":"00:00:00"},{"daysofweek":"4", "open_time":"11:00:00", "close_time":"02:00:00"},{"daysofweek":"5", "open_time":"11:00:00", "close_time":"02:00:00"},{"daysofweek":"6", "open_time":"10:00:00", "close_time":"02:00:00"},{"daysofweek":"7", "open_time":"10:00:00", "close_time":"00:00:00"}";
NSArray *arr = [str componentsSeparatedByString:@"{"];
說些什麼,而不是僅僅反對投票.. – ASH
[{ 「Hours_Of_Operation」= 「{」 daysofweek 「:」 1" , 「OPEN_TIME」: 「11:00:00」, 「CLOSE_TIME」:「00 :00:00 「},{」 daysofweek 「:」 2" , 「OPEN_TIME」: 「11:00:00」, 「CLOSE_TIME」: 「00:00:00」},{ 「daysofweek」: 「3」, 「open_time」:「11:00:00」,「close_time」:「00:00:00」},{「daysofweek」:「4」,「open_time」:「11:00:00」,「close_time」: 「02:00:00」},{ 「daysofweek」: 「5」, 「OPEN_TIME」: 「11:00:00」, 「CLOSE_TIME」: 「02:00:00」},{ 「daysofweek」:「6 「,」open_time「:」10:00:00「,」close_time「:」02:00:00「},{」daysofweek「:」7「,」open_time「:」10:00:00「,」close_time 「:」 00:00:00「}」}] – ASH