Arrays in JSON Body
Hi Guys,
I've a working that sent Http request to a REST API and is working fine,
Set Body = ##class(%ZEN.proxyObject).%New() Set Body.ElectronicMailAddressT = "ElectronicMailAddressT" Set Body.TelephoneMinimalN = "TelephoneMinimalN" Set Request.ContentType = "application/json" Set Request.Https=1 Set Request.SSLConfiguration="TLS" Set Status = ##class(%ZEN.Auxiliary.jsonProvider).%WriteJSONStreamFromObject(Request.EntityBody, Body) Set Status = Request.Post(,2)
but now I'm looking to basically add an array or data inside the body so that it looks like this:
{
"ElectronicMailAddressT": "string",
"TelephoneMinimalN": "string",
"Emp": [
{
"EmploymentPayrollNumberId": "string",
"TaxFileNumberId": "string",
"FamilyName": "string",
"GivenName": "string",
"PaymentSummary": [
{
"Tax": 0.1,
"SuperTax": 0.1,
}
]
}
]
}So, how can I create an add a list or arrays for "Emp" and "PaymentSummary" please?
Thanks Guys
Discussion (2)1
Comments
Never mind guys, I've added this kind of code and seems to be working I think.
Set Body1 = ##class(%ZEN.proxyObject).%New() Set Body1.Test = "fiel" Set Body1.Test2 = "ttss" Set Emp= ##class(%ListOfDataTypes).%New() Do Emp.Insert(Body1) Set Body.Array = Emp
Thanks
Rochdi, I converted your comment to answer, so, you can accept your answer.