/* write-json-pds1.p */
{pi-json-parameterVarDefs.i} /* parameter variable definitions */ {pi-write-json-pds1.i} /* dsOrderLog definition - no nesting */ DEFINE VARIABLE hdsOrderLog AS HANDLE NO-UNDO. DEFINE VARIABLE lRetOK AS LOGICAL NO-UNDO. hdsOrderLog = DATASET dsOrderLog:HANDLE. DATA-SOURCE dsCustomer:FILL-WHERE-STRING = "WHERE Customer.CustNum = 2 ". DATASET dsOrderLog:FILL(). ASSIGN cTargetType = "file" cFile = "dsOrderLog.json" lFormatted = TRUE cEncoding = ?. lRetOK = hdsOrderLog:WRITE-JSON(cTargetType, cFile, lFormatted). |
{"dsOrderLog": {
"ttCustomer": [ { "CustNum": 2, } ], "ttOrder": [ { "Ordernum": 94, }, { "Ordernum": 6070, } ], "ttInvoice": [ { "Invoicenum": 94, }, { "Invoicenum": 124, } ] }} |
{"dsOrderLog": {
"ttCustomer": [ { "CustNum": 2, "EmailAddress": "", "ttOrder": [ { "Ordernum": 94, "Carrier": "Standard Mail", "ttInvoice": [ { "Invoicenum": 94, } ] }, { "Ordernum": 125, "Carrier": "FlyByNight Courier", "ttInvoice": [ { "Invoicenum": 124, } ] }, ] } ] }} |