iphone JSON解析objectForKey问题

发布于 2024-10-25 23:25:17 字数 1383 浏览 1 评论 0原文

我有以下 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌若浮生 2024-11-01 23:25:18

这是因为当您对所有键(除了 Markers)执行 objectForKey: 时,您将获得一个 NSString,用于 Markers code> 你会得到一个 NSArray

Its because when you are doing objectForKey: for all your keys (exept Markers) you will get an NSString, for Markers you will get a NSArray.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文