mike
mike

Reputation: 97

iphone JSON Parse objectForKey issue

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?

Upvotes: 1

Views: 780

Answers (1)

Ludovic Landry
Ludovic Landry

Reputation: 11784

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.

Upvotes: 1

Related Questions