We are trying to consume WCF service which returns employee details in JSON Format. like:
{"d":[{"_type":"Employee:#","BigThumbNailURI":null,"ID":1,"Name":"E1"},{"_type":"Employee:#","BigThumbNailURI":null,"ID":2,"Name":"E1"}]}
From VB.net code behind when I am trying to deserialize it it's stating that
"Expecting state 'Element'.. Encountered 'Text' with name '', namespace ''."
Deserialization code snippet:
Dim serializer = New DataContractJsonSerializer(GetType(List(Of Employee)))
Dim memoryStream = New MemoryStream()
Dim s = msg.Content.ReadAsString()
serializer.WriteObject(memoryStream, s)
memoryStream.Position = 0
' Code for Deserilization
Dim obj As List(Of Employee) = serializer.ReadObject(memoryStream)
memoryStream.Close()
'Employee Class
<DataContract()> _
Public Class Employee
Private _Name As String
<DataMember()> _
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Private _id As Integer
<DataMember()> _
Public Property ID() As Integer
Get
Return _id
End Get
Set(ByVal value As Integer)
_id = value
End Set
End Property
End Class
Has anyone encountered this problem?