OE 11 issue with jsonarray class object

JamesBowen

19+ years progress programming and still learning.
OE 11 issue with jsonarray class object. See error below.

I've tried looking a the KB no entry found.oe11error0001.PNG

THIS WORKS:


Code:
USING Progress.Json.ObjectModel.JsonArray.

DEFINE VARIABLE a AS INTEGER    EXTENT 3 INITIAL [3,2,1].
DEFINE VARIABLE b AS CHARACTER  EXTENT 2 INITIAL ['Hello','world'].
DEFINE VARIABLE c AS DATE       EXTENT 2 INITIAL [9/20/10,10/10/10]. 

DEFINE VARIABLE myArr AS CLASS JsonArray    NO-UNDO.


myArr = NEW JsonArray(a). /* myArr is now [3, 2, 1] */ 
myArr:Add(TRUE). /* myArr is now [3, 2, 1, true] */
myArr:Add(b). /* myArr  is now [3, 2, 1, true, “Hello”, “world”] */ 
myArr:Add(2, c). /* myArr is now [3, 2, “2010-09-20”, “2010-10-10”, 1, true, “Hello”, “world”]

THIS DOES NOT WORK. WHY?


Code:
USING Progress.Json.ObjectModel.JsonArray.

DEFINE VARIABLE a AS INTEGER    EXTENT .
DEFINE VARIABLE b AS CHARACTER  EXTENT 2 INITIAL ['Hello','world'].
DEFINE VARIABLE c AS DATE       EXTENT 2 INITIAL [9/20/10,10/10/10]. 

DEFINE VARIABLE myArr AS CLASS JsonArray    NO-UNDO.

EXTENT (a) = 3.

a[1] = 3.
a[2] = 2.
a[3] = 1.

myArr = NEW JsonArray(a). /* myArr is now [3, 2, 1] */ 
myArr:Add(TRUE). /* myArr is now [3, 2, 1, true] */
myArr:Add(b). /* myArr  is now [3, 2, 1, true, “Hello”, “world”] */ 
myArr:Add(2, c). /* myArr is now [3, 2, “2010-09-20”, “2010-10-10”, 1, true, “Hello”, “world”] */
 
I've fired off a tech support email to Progress Software. I'll see what there response will be. I'm sort of secretly hoping it's a bug because that will be the third bug I've found in OpenEdge.
 
My workaround solution:

Code:
[FONT=&amp]USING Progress.Json.ObjectModel.JsonArray.[/FONT]

  
  [FONT=&amp]DEFINE VARIABLE a AS INTEGER    EXTENT .[/FONT]
  [FONT=&amp]DEFINE VARIABLE b AS CHARACTER  EXTENT 2 INITIAL ['Hello','world'].[/FONT]
  [FONT=&amp]DEFINE VARIABLE c AS DATE       EXTENT 2 INITIAL [9/20/10,10/10/10]. [/FONT]
  
  [FONT=&amp]DEFINE VARIABLE myArr AS CLASS JsonArray    NO-UNDO.[/FONT]
  
  [FONT=&amp]EXTENT (a) = 3.[/FONT]
  
  [FONT=&amp]a[1] = 3.[/FONT]
  [FONT=&amp]a[2] = 2.[/FONT]
  [FONT=&amp]a[3] = 1.[/FONT]
  
  [FONT=&amp]myArr = NEW JsonArray(). /* myArr is now [] */ [/FONT]
  
  [B][COLOR=#953735][FONT=&amp]/** WORKARROUND to handle variables with un-assigned extent size at compile time. **/[/FONT][/COLOR][/B]
  [B][COLOR=#953735][FONT=&amp]DEFINE VARIABLE inLoop AS INTEGER     NO-UNDO.[/FONT][/COLOR][/B]
  [B][COLOR=#953735][FONT=&amp]DO inLoop = 1 TO EXTENT(a):[/FONT][/COLOR][/B]
  [B][COLOR=#953735][FONT=&amp]    myArr:ADD( a[inLoop] ).[/FONT][/COLOR][/B]
  [B][COLOR=#953735][FONT=&amp]END.[/FONT][/COLOR][/B]
  [B][COLOR=#953735][FONT=&amp]/** WORKARROUND **/[/FONT][/COLOR][/B]
  
  [FONT=&amp]myArr:Add(TRUE). /* myArr is now [3, 2, 1, true] */[/FONT]
  [FONT=&amp]myArr:Add(b). /* myArr  is now [3, 2, 1, true, “Hello”, “world”] */ [/FONT]
  [FONT=&amp]myArr:Add(2, c). /* myArr is now [3, 2, “2010-09-20”, “2010-10-10”, 1, true, “Hello”, “world”] */[/FONT]
 
*Professor Fansworth* "Good News Everyone!" The bug has been fixed and will be released in OE 11.1 or Service Pack 1, which I believe is tentatively marked for July. I can get a hot fix now If anybody else want's it.
 
Back
Top