PxPlus User Forum
Main Board => Discussions => Programming => Topic started by: JR on February 08, 2021, 11:14:53 AM
-
0010 BEGIN
0020 DIM LOAD T${ALL}="[]"
0030 FOR I$ INDEX T${ALL}
0040 PRINT I$
0050 NEXT I$
->run
0
Why zero ??
-
We have to provide an indication that the JSON was defined as an array, thus we insert a dummy "0" entry which will indicate that this element was an array with zero elements.
For example if you did the following:
BEGIN
DIM LOAD T${ALL}="{'cats':['Dora','Heidi'],'dogs':[]}"
PRINT DIM(LIST T${ALL})
DUMP
You would see the placeholder of "dogs.0" to indicate we have an array of dogs, its just empty thus when the JSON is recreated in the DIM(LIST...) and empty array is included.