I have an Xcode project which uses an NSURLConnection to make a request to a webservice, which returns JSON.
The JSON coming back looks like this:
{"d":"{\"Graphic\":{\"HAName\":\"HSName\",\"HALogo\":\"main_menu_top_logo.png\",\"BarColour\":-16744448,\"BarButtonTextColour\":-28444,\"TextColour\":-16744448,\"BackGroundColour\":-23296,\"Error\":\"\"},\"App\":{\"App1\":true,\"App1Title\":\"Application1\",\"App2\":true,\"App2Title\":\"Application2\"Error\":\"\"},\"Version\":25,\"Error\":\"\"}"}
I am trying to parse the JSON using:
NSDictionary* json = nil;
if (responseData)
{
json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:nil];
}
But when i look at the dictionary object, it looks like this:
d = "{\"Graphic\":{\"HAName\":\"HSName\",\"HALogo\":\"main_menu_top_logo.png\",\"BarColour\":-16744448,\"BarButtonTextColour\":-28444,\"TextColour\":-16744448,\"BackGroundColour\":-23296,\"Error\":\"\"},\"App\":{\"App1\":true,\"App1Title\":\"Application1\",\"App2\":true,\"App2Title\":\"Application2\"Error\":\"\"},\"Version\":25,\"Error\":\"\"};
The dictionary only contains 1 key / value pair.
How do i get the JSON object parsed correctly?
I don’t see what the problem is, it’s given you the top level dictionary which contains lots of other dictionaries.
What were you expecting if not this? You aren’t going to get an array from this structure.