JSON Serailizing with VB.NET



我试图将嵌套对象的一些JSON序列化为字符串。但是我在对象内的数组

中遇到问题
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

但是,当我尝试将序列化字符串传递给API时,由于缺少"线"列表的方括号。

有人知道使用newtonsoft时该将它们放入谁?

 Dim Settings As New JsonSerializerSettings
 Settings.NullValueHandling = NullValueHandling.Ignore
 Dim InputString As String = JsonConvert.SerializeObject(message, Settings)

"消息"包含一个类型requestTaxes的填充对象

我认为您的属性声明有些关闭。

Public Property lines() As TaxLines

等于

Public Property lines As TaxLines

意味着您的税收只是一个实例,而不是数组。

您需要在行的末端添加paranthess,例如:

Public Property lines() As TaxLines()

我实际上需要做

Public Property lines As List(of TaxLines)

相关内容

  • 没有找到相关文章

最新更新