0

I have an NString that contains the following JSON:

str = [{"id":32,
        "date_time":"02-09-2016;23:31:29",
        "message":"tidal wave"},
       {"id":33,
        "date_time":"02-09-2016;23:33:52",
       "message":"mashup"}]

I converted this to an NSArray:

jsonObject = [NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding] options:0 error:&error];

However, when I NSLog the jsonObject, I get the following:

jsonObject = (   
        {
        "date_time" = "02-09-2016;23:31:29";
        id = 32;
        message = "tidal wave";
    },
        {
        "date_time" = "02-09-2016;23:33:52";
        id = 33;
        message = mashup;
    }
)

Why does the value in message, tidal wave, have quotes around them but not mashup?

Thanks.

Pangu
  • 3,721
  • 11
  • 53
  • 120

1 Answers1

2

This is just how it's being logged. The keys "id" and "message" are strings. jsonObject is a NSArray< NSDictionary<String, id> *> *, not related to JSON any more.

Lou Franco
  • 87,846
  • 14
  • 132
  • 192
  • Thanks Lou. 2 questions. First, if id and message keys are strings, then what type is date_time since date_time has quotes around them? Second, how would I be able to convert mashup (not sure what type that object is) into an NSString? Thanks – Pangu Feb 10 '16 at 20:52
  • mashup is probably a string. You can `po jsonObject[1][@"message"].class` – Lou Franco Feb 10 '16 at 21:31