iphone JSON解析objectForKey问题
我有以下 JSON
{
CompanyName = "Len LTD";
Date = "3/31/2011";
DimensionsOfLoad = XX;
Duration = 2;
ID = 259;
JobNotes = "Dev Test";
JobStatusId = CLOSED;
JobType = "DUMP ";
Markers = (
{
Description = "";
Latitude = "43.593063354492188";
Longitude = "-79.643798828125";
},
{
Description = Clearbridge;
Latitude = "43.660285949707031";
Longitude = "-79.651351928710938";
}
);
MaterialMeasurement = KilogramsXCentimeters;
Payment = 100;
PaymentType = "Per Hour";
Summary = "Dev Test";
Time = "12:00AMX05:00AM";
TruckTypeID = FLATBED;
TrucksRequired = 1;
TypeOfMaterial = "";
WeightOfLoad = 0;
},
这只是 JSON 的一部分,这种格式会重复很多次
我之前在我的应用程序中解析过 JSON,但问题是 Markers = .. 问题是它有另一个级别,我似乎一直在提取那些
SBJSON *parser = [[SBJSON alloc] init];
won_jobs = (NSMutableArray *)[parser objectWithString:string error:nil];
for (NSDictionary *won_job in won_jobs)
正确解析所有内容的数据值,我可以对其他字段使用 objectForKey 并且正确存储数据。
我尝试抓住标记并放入字典中,但这给我带来了问题,一次尝试我刚刚给了我空。另一个不允许我在新字典上使用 objectForKey:
有什么想法我能做什么吗?
I have the following JSON
{
CompanyName = "Len LTD";
Date = "3/31/2011";
DimensionsOfLoad = XX;
Duration = 2;
ID = 259;
JobNotes = "Dev Test";
JobStatusId = CLOSED;
JobType = "DUMP ";
Markers = (
{
Description = "";
Latitude = "43.593063354492188";
Longitude = "-79.643798828125";
},
{
Description = Clearbridge;
Latitude = "43.660285949707031";
Longitude = "-79.651351928710938";
}
);
MaterialMeasurement = KilogramsXCentimeters;
Payment = 100;
PaymentType = "Per Hour";
Summary = "Dev Test";
Time = "12:00AMX05:00AM";
TruckTypeID = FLATBED;
TrucksRequired = 1;
TypeOfMaterial = "";
WeightOfLoad = 0;
},
This is just one part of the JSON, This format repeats itself many times
I have parsed JSON in my app earlier but the issue is the Markers = ..
The issue is it has another level and i kept seem to pull those data values
SBJSON *parser = [[SBJSON alloc] init];
won_jobs = (NSMutableArray *)[parser objectWithString:string error:nil];
for (NSDictionary *won_job in won_jobs)
that parses everything properly and I can use objectForKey for the other fields and I store the data correctly.
I tried grabbing Markers and putting in dictionary but it gives me problems, one try I had just gave me null. the other wouldnt let me use objectForKey: on the new dictionary
Any Ideas what I can do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为当您对所有键(除了
Markers
)执行objectForKey:
时,您将获得一个NSString
,用于Markers
code> 你会得到一个NSArray
。Its because when you are doing
objectForKey:
for all your keys (exeptMarkers
) you will get anNSString
, forMarkers
you will get aNSArray
.