JSON parsing using NSJSONSerialization in iOS

后端 未结 6 1187
孤街浪徒
孤街浪徒 2020-12-05 16:36

I am parsing a JSON in my code. But I am getting some unexpected issues while retrieving data of parsed JSON. So let me explain my problem.

6条回答
  •  猫巷女王i
    2020-12-05 17:10

    By serializing the data, u get a json object. Json object and dictionary are different a bit.

    Instead of using:

    NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
    

    use:

    NSDictionary    *json    =   (NSDictionary*) data;
    

提交回复
热议问题