I have classes which I serialize to a JSON String. For that, I'm using Newtonsoft.Json
It looks like this:
<JsonObject()>
Public Class MyClass
Private _a;
Private _b;
Public Sub New(ByVal an As String, ByVal b as String)
_a = a
_b = b
End Sub
Public Property a As String
Get
Return _a
End Get
Protected Set(value As String)
_a = value
End Set
End Property
Public Property b As String
Get
Return _b
End Get
Protected Set(value As String)
_b = value
End Set
End Property
End Class
I put them in a list and serialize this:
JsonConvert.SerializeObject(listMyObject)
But sometimes I don't need every Property in my JSON String. Is it possible to serialize properties I passed to the constructor? As in this case?:
Public Sub New(ByVal an As String)
_a = a
End Sub