Take the 2-minute tour ×

I got something here I need to have another set of eyes look over. I've got an NSMutableDictionary that I need to convert to a JSON object and then send out to my server. The dictionary looks like this...

    data = (
            184 = 3;
            185 = "";
            186 = "";
            187 = "";
            188 = "";
            latitude = "";
            longitude = "";
            recorded = "2012-06-19 12:53:16 +0000";
        }, {
            184 = 0;
            185 = Is;
            186 = This;
            187 = "Working?";
            188 = "I think so.";
            latitude = "";
            longitude = "";
            recorded = "2012-06-19 12:54:26 +0000";

    deviceID = b1c96c4467a8bcca97a826ad9941a10a;
    key = 6puwX3v2;
    method = putSurveyData;
    responses = 2;
    surveyID = 84;

So far, no problems, but as soon as I go to convert that dictionary to a JSON object using NSJSONSerialization it crashes my app. The above dictionary is called mainDictionary and I use the following line to convert to JSON.

NSData *jsonData = [NSJSONSerialization dataWithJSONObject:mainDicitionary options:kNilOptions error:nil];

If I remove the nested dictionaries from the 'data' key, it works fine. I have even tried to put a common array in the 'data' key, and that works also. It just seems to bomb out as soon as I stick an NSMutableDictionary in there. Is there something simple i'm missing?


share|improve this question
add comment

1 Answer

I found the answer. The "recorded" field above was actually an [NSDate date] rather than a string representation of the date stamp. I cast it to a string and all is fine.

share|improve this answer
Thanks I was having the same problem –  William T. Apr 24 '13 at 23:34
add comment

Your Answer


