JavascriptSerializer exception

I have the following data:

{"data": {"identifier": "7IaWnXo", "name": NULL, "Description": NULL, "DateTime": 1397926970, "type": "image / PNG", "animated" false, "width" : 60, "height": 60, "size": 1277, "opinion": 0, "bandwidth": 0, "favorite" false "NSFW": zero, "partition": zero, "deletehash": "KYIfVnHIWWTPifh "," communication ":" http://i.imgur.com/7IaWnXo.png "}," success ": true," status ": 200}

and I'm trying to serialize it to this:

public struct ImageInfoContainer
    {
        public ImageInfo data {get; set;}
        bool success { get; set; }
        string status { get; set; }
    }
    public struct ImageInfo
    {
        public string id {get; set;}
        public string title { get; set; }
        public string url { get; set; }
        public string description {get; set;}
        public string datetime {get; set;}
        public string type {get; set;}
        public string animated {get; set;}
        public int width {get; set;}
        public int height {get; set;}
        public int size {get; set;}
        public int views {get; set;}
        public int bandwidth {get; set;}
        public bool favourite {get; set;}
        public bool nsfw {get; set;}
        public string section {get; set;}
        public string deletehash {get; set;}
        public string link {get; set;}
    }

and I get:

'System.InvalidOperationException' System.Web.Extensions.dll,

: null .

?

+4
1

JSON: nsfw null.
ImageInfo struct, nsfw boolean ( , true false)

2 .

  • JSON, null nsfw.
  • nullable bool: public bool? nsfw {get; set;}

, true, false null nsfw, .

Nullable<bool> bool? - .
Nullable Types

+10

Source: https://habr.com/ru/post/1537222/


All Articles