I
Ian Stewart
Guest
I am having a problem with Progress READ-JSON where it is not accepting the JSON that was output by WRITE-JSON. We are using TRACKING-CHANGES with a dataset with a nested data-relation.
OUTPUT TO "debug.txt".
DEFINE VARIABLE lcString AS LONGCHAR NO-UNDO.
DEFINE VARIABLE hdsBox AS HANDLE NO-UNDO.
DEFINE VARIABLE lOk AS LOGICAL NO-UNDO.
DEFINE TEMP-TABLE ttEmployee NO-UNDO
BEFORE-TABLE ttEmployeeBefore
FIELD eid AS INTEGER
FIELD empname AS CHAR.
DEFINE TEMP-TABLE ttBox NO-UNDO
BEFORE-TABLE ttBoxBefore
FIELD eid AS INTEGER SERIALIZE-HIDDEN
FIELD boxid AS INTEGER
FIELD boxdesc AS CHAR.
DEFINE DATASET dsBox FOR ttEmployee, ttBox
DATA-RELATION relat1 FOR ttEmployee, ttBox RELATION-FIELDS (ttEmployee.eid, ttBox.eid) NESTED.
CREATE ttEmployee.
CREATE ttBox.
ASSIGN ttEmployee.eid = 1
ttEmployee.empname = "Ian"
ttBox.eid = 1
ttBox.boxid = 10
ttBox.boxdesc = "Ians box".
hdsBox = DATASET dsBox:HANDLE.
ASSIGN TEMP-TABLE ttEmployee:TRACKING-CHANGES = YES
TEMP-TABLE ttBox:TRACKING-CHANGES = YES.
CREATE ttBox.
ASSIGN ttBox.eid = 1
ttBox.boxid = 11
ttBox.boxdesc = "Stewarts box"
/*ttEmployee.empname = "Stewart"*/ .
ASSIGN lOk = hdsBox:WRITE-JSON("LONGCHAR", lcString,FALSE , "UTF-8", FALSE, FALSE, TRUE).
ASSIGN TEMP-TABLE ttEmployee:TRACKING-CHANGES = NO
TEMP-TABLE ttBox:TRACKING-CHANGES = NO.
MESSAGE lOk ERROR-STATUS:GET-MESSAGE(1) SKIP.
MESSAGE STRING(lcString) SKIP.
ASSIGN lOk = hdsBox:READ-JSON("LONGCHAR":U, lcString, "EMPTY":U) NO-ERROR.
MESSAGE lOk ERROR-STATUS:GET-MESSAGE(1) SKIP.
This example generates the following output:
yes
{"dsBox":{"prods:hasChanges":true,"ttEmployee":[{"eid":1,"empname":"Ian","ttBox":[{"boxid":10,"boxdesc":"Ians box"},{"prods:id":"ttBox96513","prods:rowState":"created","boxid":11,"boxdesc":"Stewarts box"}]}],"prods:before":{}}}
no Error parsing JSON: expected string, but found bracket. (15358)
If I take out the comment on line 35, then it works, which leads me to believe it is a Progress bug.
Continue reading...
OUTPUT TO "debug.txt".
DEFINE VARIABLE lcString AS LONGCHAR NO-UNDO.
DEFINE VARIABLE hdsBox AS HANDLE NO-UNDO.
DEFINE VARIABLE lOk AS LOGICAL NO-UNDO.
DEFINE TEMP-TABLE ttEmployee NO-UNDO
BEFORE-TABLE ttEmployeeBefore
FIELD eid AS INTEGER
FIELD empname AS CHAR.
DEFINE TEMP-TABLE ttBox NO-UNDO
BEFORE-TABLE ttBoxBefore
FIELD eid AS INTEGER SERIALIZE-HIDDEN
FIELD boxid AS INTEGER
FIELD boxdesc AS CHAR.
DEFINE DATASET dsBox FOR ttEmployee, ttBox
DATA-RELATION relat1 FOR ttEmployee, ttBox RELATION-FIELDS (ttEmployee.eid, ttBox.eid) NESTED.
CREATE ttEmployee.
CREATE ttBox.
ASSIGN ttEmployee.eid = 1
ttEmployee.empname = "Ian"
ttBox.eid = 1
ttBox.boxid = 10
ttBox.boxdesc = "Ians box".
hdsBox = DATASET dsBox:HANDLE.
ASSIGN TEMP-TABLE ttEmployee:TRACKING-CHANGES = YES
TEMP-TABLE ttBox:TRACKING-CHANGES = YES.
CREATE ttBox.
ASSIGN ttBox.eid = 1
ttBox.boxid = 11
ttBox.boxdesc = "Stewarts box"
/*ttEmployee.empname = "Stewart"*/ .
ASSIGN lOk = hdsBox:WRITE-JSON("LONGCHAR", lcString,FALSE , "UTF-8", FALSE, FALSE, TRUE).
ASSIGN TEMP-TABLE ttEmployee:TRACKING-CHANGES = NO
TEMP-TABLE ttBox:TRACKING-CHANGES = NO.
MESSAGE lOk ERROR-STATUS:GET-MESSAGE(1) SKIP.
MESSAGE STRING(lcString) SKIP.
ASSIGN lOk = hdsBox:READ-JSON("LONGCHAR":U, lcString, "EMPTY":U) NO-ERROR.
MESSAGE lOk ERROR-STATUS:GET-MESSAGE(1) SKIP.
This example generates the following output:
yes
{"dsBox":{"prods:hasChanges":true,"ttEmployee":[{"eid":1,"empname":"Ian","ttBox":[{"boxid":10,"boxdesc":"Ians box"},{"prods:id":"ttBox96513","prods:rowState":"created","boxid":11,"boxdesc":"Stewarts box"}]}],"prods:before":{}}}
no Error parsing JSON: expected string, but found bracket. (15358)
If I take out the comment on line 35, then it works, which leads me to believe it is a Progress bug.
Continue reading...