I have write the follow code to get the data formated as JSON
{"billNumber":"0003","entityActivityId":572,"customerFullName":"التوكيلات التجارية","customerMobileNumber":"0506436506","customerPreviousBalance":0,"issueDate":"2022-08-16","expireDate":"2022-09-23","billItemList":{"name":"*","quantity":1,"unitPrice":900,"discount":0,"discountType":"FIXED","vat":"0.15"}}
but I want to be as follwoing:
the deferrence is the [] in the details data.
{"billNumber":"0003","entityActivityId":572,"customerFullName":"التوكيلات التجارية","customerMobileNumber":"0506436506","customerPreviousBalance":0,"issueDate":"2022-08-16","expireDate":"2022-09-23","billItemList":[{"name":"*","quantity":1,"unitPrice":900,"discount":0,"discountType":"FIXED","vat":"0.15"}]}
my code is :
dt1 = dt.ToString("yyyy-MM-dd")
dt2 = dt.AddDays(7).ToString("yyyy-MM-dd")
Dim b As New billItemList With
{
.name = "*",
.quantity = 1,
.unitPrice = txtSubTotal.Value,
.discount = txtDiscountValue.Value,
.discountType = "FIXED",
.vat = 0.15
}
Dim person = New EfaaAPI() With {
.billNumber = txtInvNo.Value,
.entityActivityId = 572,
.customerFullName = CN,
.customerMobileNumber = txtTelNo.Value,
.issueDate = dt1,
.expireDate = dt2,
.billItemList = b
}
Dim json = JsonConvert.SerializeObject(person)
my class is :
Public Class EfaaAPI
Public Property billNumber As String 'optional
Public Property entityActivityId As Integer
Public Property customerFullName As String
Public Property customerMobileNumber As String
Public Property customerPreviousBalance As Integer
Public Property issueDate As String 'YYYY-MM-DD
Public Property expireDate As String 'YYYY-MM-DD
Public Property billItemList As New billItemList()
End Class
Public Class billItemList
Public Property name As String
Public Property quantity As Integer
Public Property unitPrice As Integer
Public Property discount As Integer
Public Property discountType As String
Public Property vat As String
End Class
any idea regarding this issue ??
2
Answers
try changing :
to
and try changing :
to :
you need to fix the class
change the name of class
and code