[英]Serializing an image in a dataTable with datacontractjsonserializer
I am serializing an DataTable with datacontractjsonserializer and passing it as JSON in C#. 我正在使用datacontractjsonserializer序列化DataTable并将其作为JSON在C#中传递。 The problem im having is all the fields gets serialized as strings.
我有的问题是所有字段都被序列化为字符串。 FirstName and LastName is correct but the Picture field get serialized as
名和姓是正确的,但图片字段被序列化为
"System.Byte[]" string and not an object.
“ System.Byte []”字符串,而不是对象。
Please advise how do I serialize it as an object an pass it via JSON ? 请告知如何将其序列化为对象并通过JSON传递给它?
covert your byte image to string like this 像这样将您的字节图像隐藏为字符串
string result=Encoding.ASCII.GetString(Your_Image);
then append the result to your fields. 然后将结果附加到您的字段。 In the other side do this split your fields to get your fields by a splitter then you can get your image like this
在另一面,将您的字段拆分成一个拆分器,然后可以像这样获取图像
byte[]your_image= Encoding.ASCII.GetBytes(Result_After_splitting) ;
Hope it helps 希望能帮助到你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.