将json字节数组图像转换为c#list

时间:2012-11-08 06:12:47

标签: asp.net json image web-services bytearray

JSON字符串:

 { "Result": 
           [
                { "food_photo":255,216,255,224,0,16,74,70,73,70,0,1.....4,255,217],
                  "qty":"12",
                  "time":"23",
                  "cost":null
                }
           ]
   }

我的问题:如何将food_photo转换为列表?

仅供参考:我在班级中使用public byte[] food_photo,但在执行列表时显示为空。

1 个答案:

答案 0 :(得分:1)

尝试将food_photo反序列化为字符串并使用string.split方法

string deserializedFoodPhoto = "255,216,255,224,0,16,74,70,73,70,0,4,255,217";
var photoInList = deserializedFoodPhoto.Split(',').Select(i => byte.Parse(i)).ToList();