【发布时间】:2014-10-03 13:52:09
【问题描述】:
我在一个字符串中有一个字节数组,我试图将它序列化为一个对象,字节数组是在 iPhone 上生成的,但接收服务是 VB.net 我收到错误无法解析值“-1”当进行 serializer.ReadObject 调用并设法让 c# 使用
将字节数组视为有效时,作为“字节”类型byte[] ba = new byte[] { 208, 125, 138, 15, unchecked((byte)-1), 211, 1, 74, 148, unchecked((byte)-9), 82, 10, 245, 193, 115, 64, 108, 12 };
但未选中的元素在 VB 中似乎不存在,我正在努力解决问题。
提前致谢
对象是
Public Class GetVehicleListInput : Inherits BaseInput
End Class
基本输入是
Public Class BaseInput
Private abyteExternalIdentifier As Byte() = Nothing
Public Property ExternalIdentifier() As Byte()
Get
Return abyteExternalIdentifier
End Get
Set(ByVal value As Byte())
abyteExternalIdentifier = value
End Set
End Property
Public Sub New()
End Sub
End Class
我的班级是
Dim mystring As String = "{""ExternalIdentifier"":[208,125,138,15,-1,211,1,74,148,-9,82,10,245,193,115,64,108,12]}"
Dim serializer As New Json.DataContractJsonSerializer(GetType(GetVehicleListInput))
Dim thing As GetVehicleListInput
Using stream As MemoryStream = New MemoryStream(Encoding.UTF8.GetBytes(mystring))
thing = DirectCast(serializer.ReadObject(stream), GetVehicleListInput)
End Using
End Sub
【问题讨论】:
-
你的意思是 iPhone 发送的字符串是一系列数字,对吧?
-
它发送 myString 的值