Сериализация JSON, выдающая неожиданную ошибку

Я пытаюсь отменить реализацию NSData до NSARRAY или NSDICTIONARY, но NJSONSERIALIZATION выдает ошибку 1. Я успешно использую метод много раз, но я не знаю, почему в данном конкретном случае это не работает.

NSMutableURLRequest *request = [WebMethod GetMenuForRestaurant:restaurantid];

NSHTTPURLResponse *response = nil;

NSData *responseData;
NSError *error = nil;

for (int c = 0; c<5; c++) {
    //make the request
    responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

    //some hardcode
    if (responseData!=nil)
        c = 10;
}

if (responseData==nil)
    return nil;
NSDictionary* jsonArray = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&error];

Вот мой JSON:

{"Sections":[{"sectionname":"Main","Products":     [{"ProductName":"hamburguer","Price":250.0},{"ProductName":"pasta","Price":300.0},{"ProductName":"pizza","Price":350.0}]},{"sectionname":"desserts","Products":[{"ProductName":"brownie","Price":200.0},{"ProductName":"helado","Price":150.0}]},{"sectionname":"entries","Products":[{"ProductName":"chips","Price":125.0},{"ProductName":"salad","Price":100.0},{"ProductName":"weed","Price":1000.0}]}]}

Пытаясь отменить его, сериализация JSON дает мне эту ошибку:

(<invalid>) [0] = <error: expected ']'
error: 1 errors parsing expression
>

0 ответов

Другие вопросы по тегам