I have added DataMemeber to my object properties to change settings when serializing to JSON, however it is not using them. I have attempted to change the name, as well as emitting default values.
My reason for trying to do this is I want to ignore a property if it is at its default value.
I am attempting to use the Microsoft libraries and not the Newtonsoft ones.
<DataMember(EmitDefaultValue:=True, IsRequired:=False, Name:="addressTable")> Public Property addressTable() As String
Get
Return _AddressTable
End Get
Set(ByVal value As String)
_AddressTable = value
End Set
End Property
Public Function gObjToStr(ByVal InputObject As Object) As String
Dim stream1 As New IO.MemoryStream
Dim ser As Runtime.Serialization.Json.DataContractJsonSerializer = New Runtime.Serialization.Json.DataContractJsonSerializer(InputObject.GetType)
ser.WriteObject(stream1, InputObject)
stream1.Position = 0
Dim sr As New IO.StreamReader(stream1)
Dim OutString As String = Nothing
Return sr.ReadToEnd
End Function