Could not cast value of type '__NSArrayM' to 'NSDictionary'

后端 未结 2 1164
一整个雨季
一整个雨季 2021-01-28 22:57

I have a json.I am trying to parse that with that code.But its says

Could not cast value of type \'__NSArrayM\' to \'NSDictionary\'

<
相关标签:
2条回答
  • 2021-01-28 23:22

    What it's telling you is that the JSON object that you're parsing is not a dictionary, it's an array. So if you change it so that you treat its value as an array instead of a dictionary, you'll be able to iterate over that.

    You need to reevaluate your JSON to ensure that it's structured the way you think it is. It would also be useful if you posted the JSON that you're trying to parse so that we can see it's structure as well.

    0 讨论(0)
  • 2021-01-28 23:32

    The root object in your data is an array, not a object (dictionary).

    You need to dynamically decide how to handle your JSON depending on the deserialized object.

    0 讨论(0)
提交回复
热议问题