When I Deserialize this object everything works except for Images? The only way I have figured out how to get the images out is to use the method 'GetImages()'. I would like to not have to use this a method where I return a Dictionary Key results. I've tried structuring the object so many different way, but have yet to successfully find the answer.
Here is the object.
public class Item
{
public int itemId { get; set; }
public double systemSku { get; set; }
public int itemECommerceID { get; set; }
public Dictionary<string, List<Image>> Images { get; set; }
public Category Category { get; set; }
public List<Image> GetImages()
{
return this.Images["Image"];
}
}
Image Class:
public class Image
{
public int imageID { get; set; }
public string description { get; set; }
public string filename { get; set; }
public int ordering { get; set; }
public string publicID { get; set; }
public string baseImageURL { get; set; }
public int itemID { get; set; }
public int itemMatrixID { get; set; }
public string imageUrl
{
get
{
return string.Format("{0}{1}.jpg", baseImageURL, publicID);
}
}
}
Excerpt of serialization code:
var stream = await response.Content.ReadAsStreamAsync();
StreamReader reader = new StreamReader(stream);
JavaScriptSerializer js = new JavaScriptSerializer();
var tmpObj = js.Deserialize<dynamic>(reader.ReadToEnd());
TResult obj = js.Deserialize<TResult>(js.Serialize(tmpObj[key]));