Создание JSON с помощью VB.NET и еще json.net в приложении windows
Попробуйте создать файл JSON с помощью vb.net и еще json.net в приложении windows, но не удалось сгенерировать нужный формат файла JSON.
формат JSON:
{ "CompCode": "COMP0001", "fp": "072018", "gt": 0, "cur_gt": 0, "b2b": [ { "patry": "ABC Company", "inv": [ { "inum": "00164", "idt": "01-07-2018", "val": 525, "itms": [ { "num": 1, "itm_det": { "txval": 500, "rt": 5 } } ] } ] } ] }
Что я уже пробовал:
<pre lang="vb"> Private Sub cmdGenerateJson_Click(sender As Object, e As EventArgs) Handles cmdGenerateJson.Click Dim JsonHeader As New ClsHeader() ''Main JsonHeader.compcode = "COMP0001" JsonHeader.fp = "0.00" JsonHeader.gt = 0 JsonHeader.cur_gt = 0 ''Party Dim b2 As New ClsParty b2.party = "ABC Company" ''Inv Dim InvDet As New ClsInvoice InvDet.inum = 111 InvDet.idt = "25-08-2018" InvDet.val = 525 ''Item Dim cid As New ClsItem cid.num = 1 ''Item details Dim itmdet As New ClsItemDetails itmdet.txval = 500 itmdet.rt = 5 JsonHeader.b2b.Add(b2) Dim jsonString As String = JsonConvert.SerializeObject(JsonHeader) TextBox1.Text = jsonString End Sub End Class Public Class ClsHeader Public Property compcode As String Public Property fp As String Public Property gt As Int64 Public Property cur_gt As Int64 Public Property b2b As New List(Of ClsParty) End Class Public Class ClsParty Public Property party As String Public Property inv As New List(Of ClsInvoice) End Class Public Class ClsInvoice Public Property inum As String Public Property idt As String Public Property val As Double Public Property itms As New List(Of ClsItem) End Class Public Class ClsItem Public Property num As Integer Public Property itm_det As New List(Of ClsItemDetails) End Class Public Class ClsItemDetails Public Property txval As Double Public Property rt As Double End Class
Patrice T
Какой результат вы получаете ?