OS/2, eCS & ArcaOS - Technical > Programming

JSon to Rexx (stem)

<< < (6/6)

Jan-Erik Lärka:
Hello,

I used:
set rextrace=on
and stepped thorugh the code...
It parse almost all of the file, but it stumble on the last

--- Code: ---"code":0}
--- End code ---
and never complete as it can't handle that last section.
The result is that the code skip past and return the same text over and over again in rapid succession, thus eventually look up the computer.

The short term solution would be just to remove what's left, but I'll look into it somewhat to see what I can do about it.

Recursion:
Problems usually result in that the interpreter exit abnormally with a message that contain a call to the same function, though visually offset from the previous. Rexx can not handle that many levels of recursion s0 it's possible to write code that can parse an advanced file. One has to handle such solutions with queues or stacks.


--- Code: ---call bla( param_1, param_n )
   call bla( param_1, param_n )
      call bla( param_1, param_n )
         call bla( param_1, param_n )
            call bla( param_1, param_n )
               call bla( param_1, param_n )
                  call bla( param_1, param_n )
                     call bla( param_1, param_n )

--- End code ---

Jan-Erik Lärka:
Ok,

3 issues:

1. The code need that a json file begin with "[{" and end with "}]"
  It can be easily be resolved with


--- Code: ---   IF LEFT( !_str_!, 1 ) = '{' THEN
      !_str_! = '['||!_str_!||']'
--- End code ---
right after

--- Code: ---!_str_! = STRIP( ARG(1) )
--- End code ---

2. The mentioned ending of the file has to be coded into the part that handle ':'
    Tested here and done.

3. The code focus on key'='value (including such lists) and not on value lists only.
    An additional section has to be added that take care of the list
"proxy_serverlist":[...]

Navigation

[0] Message Index

[*] Previous page

Go to full version