My My, we have variable length, variable type, non-destructi

Posted by jmls on 06-Jan-2012 13:27

in the true spirt of  subverting something to do something else, may I present a json object for manipulating arrays ...

def var test1 as char extent 5 init ["t1","t2","t3","t4","t5"].

def var test2 as int extent 5 init [1,2,3,4,5].

def var array1 as Progress.Json.ObjectModel.JsonArray.

array1 = new Progress.Json.ObjectModel.JsonArray().

def var i as int.

/** add 10 items to the array */

do i = 1 to 10:

  array1:Add("Item_" + string(i)).

end.

/** add the 11th element */

array1:add(today).

/** get the number of elements in the array */

message array1:length view-as alert-box.

/** get the 5th element */

message array1:GetCharacter(5) view-as alert-box.

/** get the 11th element */

message array1:GetDate(11) string(array1:GetJsonText(11)) view-as alert-box.

/** add a lot at once */

array1:add(test1).

/** get the number of elements in the array */

message array1:length array1:GetCharacter(array1:length) view-as alert-box.

/** insert elements into the array */

array1:add(0,test2).

/** get the number of elements in the array */

message array1:length string(array1:getjsontext(1)) array1:GetCharacter(array1:length) view-as alert-box.

message "length = " array1:length  skip

        "item @ 16  = " string(array1:getjsontext(16)) view-as alert-box.

/** remove the element at 16 elements */

array1:Remove(16).

message "length = " array1:length  skip

        "item @ 16  = " string(array1:getjsontext(16)) view-as alert-box.

/** remove the first 5 elements */

message "length = " array1:length  skip

        "item @ 1  = " string(array1:getjsontext(1)) view-as alert-box.

array1:Remove(1,5).

message "length = " array1:length  skip

        "item @ 1  = " string(array1:getjsontext(1)) view-as alert-box.

this works on windows 11 - can someone test it on 10 ? And on unix 10 / 11

no speed tests done yet, except that it can add 1000 elements per ms

Comments ?

All Replies

Posted by Admin on 06-Jan-2012 13:33

this works on windows 11 - can someone test it on 10 ? And on unix 10 / 11

Comments ?

Cannot test it on OE10. The Progress.Json objects were only added in OE11.

Posted by Peter Judge on 06-Jan-2012 13:39

this works on windows 11 - can someone test it on 10 ? And on unix 10 / 11

Windows 11? Progress.JSON.* classes were only added in OE 11. But if you close one eye and quint a bit, it looks a bit like a collection (List), dunnit?

-- peter

Posted by jmls on 06-Jan-2012 13:39

bummer. Nevermind. Interesting nevertheless.

Posted by Thomas Mercer-Hursh on 06-Jan-2012 13:51

Let me guess that this would not work for the most interesting case, i.e., objects...

Posted by jmls on 06-Jan-2012 13:59

it certainly does

On 6 January 2012 19:51, Thomas Mercer-Hursh

Posted by jmls on 06-Jan-2012 14:03

crap. I misread Progress.Json.ObjectModel

sorry.

However, there is a construct for

CONSTRUCTOR PUBLIC JsonArray (p1 AS CLASS Progress.Lang.Object EXTENT)

...

more tests needed.


Posted by Thomas Mercer-Hursh on 06-Jan-2012 14:17

If it would handle objects, I'd like to benchmark it in my collection benchmark tests.

Posted by jmls on 06-Jan-2012 14:19

it doesn't. poo.

On 6 January 2012 20:17, Thomas Mercer-Hursh

Posted by Thomas Mercer-Hursh on 06-Jan-2012 14:29

I'm glad there is a period after the t or we might have a different kind of debugging to do ...

I'm not surprised since JSON, like XML, is basically ASCII data, so we would need a built-in serialization capability ... and that probably wouldn't help performance any!

This thread is closed