我在将一些数据从JSON解析为NSDictionary时遇到了一些问题,JSON内部的数据遵循以下模式:
object = (
{
"field1" = 2;
"field2" = "something";
array = {
"field3" = "anotherThing";
booleanField = true;
{
};
otherThing = "yay";
};
},
{
"field1" = 2;
"field2" = "something";
array = {
"field3" = "anotherThing";
booleanField = true;
{
};
otherThing = "yay";
};
} )
如何使用NSArray
创建NSDictionaries
?
我希望我只是解释它
感谢您的帮助
答案 0 :(得分:0)
NSError *jsonParsingError = nil;
NSArray *contentArray = [NSJSONSerialization
JSONObjectWithData:[aContentString dataUsingEncoding:NSUTF8StringEncoding]
options:0
error:&jsonParsingError];
希望它有所帮助。
答案 1 :(得分:-1)
可能重复(How to convert JSON serialized data to NSDictionary)
如果您的回复是object = (...);
NSError *err;
NSDictionary *dictObject = [NSJSONSerialization JSONObjectWithData:yourData options:NSJSONReadingMutableContainers error:&err];
NSArray *arr = dictObject[@"object"];
如果您的回复是(...)
;
NSError *err;
NSArray *arrObject = [NSJSONSerialization JSONObjectWithData:yourData options:NSJSONReadingMutableContainers error:&err];
也许它会帮助你。