Min
Min

Reputation: 29

Vb.net deserialize object in json

I don't know what to put above the variable to make deserialize the object and I can't find it anywhere... (I don't want to use json.net)

here's the class code

<Serializable()> _
 Public Class O
<???????()> _
Private Likes As Decimal

Public Sub New(ByVal l As Decimal)
    Likes = l
End Sub
End Class

and here's the main code

Dim ser As New DataContractJsonSerializer(GetType(O))
    Dim ms As New MemoryStream(Encoding.UTF8.GetBytes(resp))
    Dim o As O= CType(ser.ReadObject(ms), O)
    ms.Close()
    ms.Dispose()

So what should I put instead of ????

Upvotes: 0

Views: 84

Answers (1)

sloth
sloth

Reputation: 101052

You have to make the Likes member public.

Public Class O

    Public Likes As Decimal

    Public Sub New(ByVal l As Decimal)
        Likes = l
    End Sub

End Class

Upvotes: 1

Related Questions