Cannot deserialize the JSON array (e.g. [1,2,3]) into type ' ' because type requires JSON object (e.g. {“name”:“value”}) to deserialize correctly

前端 未结 5 1643
耶瑟儿~
耶瑟儿~ 2020-11-22 16:19

I have this JSON:

[
    {
        \"Attributes\": [
            {
                \"Key\": \"Name\",
                \"Value\": {
                    \"Value         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 17:22

    Can't add a comment to the solution but that didn't work for me. The solution that worked for me was to use:

    var des = (MyClass)Newtonsoft.Json.JsonConvert.DeserializeObject(response, typeof(MyClass)); 
    return des.data.Count.ToString();
    

    Deserializing JSON array into strongly typed .NET object

提交回复
热议问题