Question
· Jan 15, 2018

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
Log in or sign up to continue