我正在开发一个应用,因为我需要将Json数据转换为NSDictionary 。我尝试了一些方法,但我无法以适当的格式获得字典。请任何人都可以建议我。下面是一个需要转换的Json格式。提前致谢。
{
TUM = {
Category = "Social,games";
CategoryStatus = "1,0";
scs = 1;
webdetail =(
{
app = facebook;
cat = Social;
days = "1,2,5";
daytime1 = "10:30-11:30,13:30-14:30,18:30-19:30";
daytime2 = "06:30-07:30,10:30-11:30,13:30-16:30";
daytime3 = "";
daytime4 = "";
daytime5 = "10:30-11:30,12:30-13:30";
daytime6 = "";
daytime7 = "";
lck = 2;
},
{
app = gmail;
cat = Social;
days = "1,5";
daytime1 = "10:30-11:30,18:30-19:30";
daytime2 = "";
daytime3 = "";
daytime4 = "";
daytime5 = "10:30-11:30,22:30-23:30";
daytime6 = "";
daytime7 = "";
lck = 2;
}
);
};
}
答案 0 :(得分:1)
您可以使用NSJSONSerialization class来解析JSON,它包含将JSON数据转换为NSArray或NSDictionary的逻辑。
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
答案 1 :(得分:0)
尝试使用此代码
NSError *error;
NSDictionary *jsondictionary = [NSJSONSerialization JSONObjectWithData:jsonData
options:NSJSONReadingMutableContainers
error:&error];