我有以下数据保存在一个NSString
中:
{
Key = ID;
Value = {
Content = 268;
Type = Text;
};
},
{
Key = ContractTemplateId;
Value = {
Content = 65;
Type = Text;
};
},
我想将这个数据转换成一个包含键值对的 NSDictionary
。
我首先尝试将 NSString
转换为 JSON 对象,如下所示:
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
然而,当我尝试时:
NSString * test = [json objectForKey:@"ID"];
NSLog(@"TEST IS %@", test);
我收到的值是NULL
。
有人能提供一下问题所在吗?