Reputation: 81
I am trying to serialise some JSON from nested objects into a string. However I am having issues with the arrays within the objects
Class RequestTaxes
Public Property usrname As String
Public Property pswrd As String
Public Property isAudit As Boolean
Public Property currn As String
Public Property lines() As TaxLines
End Class
Class TaxLines
Public Property debCredIndr As Integer
Public Property goodSrvCd As String
Public Property grossAmt As Double
Public Property lnItmId As String
Public Property qnty As Double
Public Property trnTp As Integer
Public Property accntDt As DateTime
Public Property custVendName As String
Public Property custVendCd As String
Public Property orgCd As String
End Class
However when I try to pass the serialised string to the API It is refused because the square brackets around the "lines" list are missing.
Does anyone know who to put these in when using Newtonsoft?
Dim Settings As New JsonSerializerSettings
Settings.NullValueHandling = NullValueHandling.Ignore
Dim InputString As String = JsonConvert.SerializeObject(message, Settings)
"message" contains a populated object of type RequestTaxes
Upvotes: 0
Views: 731
Reputation: 81
I actually needed to do
Public Property lines As List(of TaxLines)
Upvotes: 0
Reputation: 2750
I think you have your property declarations a bit off.
Public Property lines() As TaxLines
is equivalent to
Public Property lines As TaxLines
meaning that your TaxLines is only a single instance, not an array.
You need to add parantheses at the end of the line like so:
Public Property lines() As TaxLines()
Upvotes: 1