0

我的 json 数组:

 {"lstResult":[{"food_photo":[255,216,255,224,0,16,74,70,73,70,0,1........3,5],"food":"12","qty_uom":"Pcs","unit":null}]}

我的 C# 类:

 public class lstresult
    {
    public photo[] lstResult{get;set;}
    }

public class photo
{
public byte[] food_photo{get;set;}
}
public class Food
{
    public photo[] food_photo { get; set; }
    public int food_qty { get; set; }
    public string qty_uom { get; set; }
    public string unitcost { get; set; }
}

我的问题:

我的 json 字符串包含一个“food_photo”键如何将此字节数组转换为图像?或转换为asp.net中的列表提前谢谢

4

2 回答 2

0
public class LstFooddtlResult
{
    public List<int> food_photo { get; set; }
    public string food { get; set; }
    public string qty_uom { get; set; }
    public string unitcost { get; set; }
}

public class RootObject
{
    public List<LstFooddtlResult> lstResult { get; set; }
}
于 2012-11-10T08:23:57.893 回答
0

使用Javascript 序列化器

这是一些关于使用 Javascript Serializer 的示例代码

string json = "[{Name:'John Simith',Age:35},{Name:'Pablo Perez',Age:34}]"; 

public class Person
{
   public int Age {get;set;}
   public string Name {get;set;}
}

JavaScriptSerializer js = new JavaScriptSerializer();
Person [] persons =  js.Deserialize<Person[]>(json);
于 2012-11-07T11:05:14.863 回答