public class Thumbnails
{
    public string 640x640 { get; set; }
    public string 50x50 { get; set; }
    public string 320x320 { get; set; }
    public string 200x200 { get; set; }
    public string 120x120 { get; set; }
    public string 100x100 { get; set; }           
}
"thumbnails":
{
    "640x640":"https://assets.mixrad.io/asset/artists/640x640/6500453.jpg",
    "50x50":"https://assets.mixrad.io/asset/artists/50x50/6500453.jpg",
    "320x320":"https://assets.mixrad.io/asset/artists/320x320/6500453.jpg",
    "200x200":"https://assets.mixrad.io/asset/artists/200x200/6500453.jpg",
    "120x120":"https://assets.mixrad.io/asset/artists/120x120/6500453.jpg",
    "100x100":"https://assets.mixrad.io/asset/artists/100x100/6500453.jpg"
}

Error: The name "x640" doesnt exit in the current context.

I can't get thumbail by json. How to sovle it,please?

1 Answers

2
NASSER On

You cannot declare, any property, method, variable, class etc. starting from digits. You can use [JsonProperty("name")] attribute

public class Thumbnails
{
   [JsonProperty("640x640")]
   public string Image640 { get; set; }

   [JsonProperty("50x50")]
   public string Image50 { get; set; }

   [JsonProperty("320x320")]
   public string Image320 { get; set; }

   [JsonProperty("200x200")]
   public string Image200 { get; set; }

   [JsonProperty("120x120")]
   public string Image120 { get; set; }

   [JsonProperty("100x100")]
   public string Image100 { get; set; }
}

Note: If you have not Json.Net package, then install it from here.