OS/2, eCS & ArcaOS - Technical > Programming

JSon to Rexx (stem)

<< < (5/6) > >>

Mentore:

--- Quote from: Neil Waldhauer on May 20, 2021, 08:32:33 pm ---I'm waking this thread up after a long time. I started to write a REXX program to control the GL.iNet family of routers. These tiny routers can provide wireless support. But the user interface does not work with Firefox 45.

So I use curl and an API to control the router. So far, I can go to some WiFi hotspots, connect to them and surf the internet.

In order to do this, I needed to interpret the JSON file that CURL returns. So here I am. I used this:
  * Filename: JSon2Rx.cmd
 *   Author: Jan-Erik
 *  Created: Sat Feb 23 2013
 *  Purpose: Interpret a JSon-file and place in stem

I found it had a problem with one of the files I got. So I tried this one:
/*
 * Filename: fromJSon.cmd
 *   Author: JANERIK
 *  Created: Sat Feb  3 2018

Amazingly, this hangs my ArcaOS computer. I type

fromJSon curldns.txt

and it never completes. Is there something wrong with my computer, or is fromJSon.cmd doing something wierd?

--- End quote ---

First question: did you try to validate the json file?

A REXX script should not be able to hang OS/2, but I'm afraid this may happen.
Mentore

Lars:
What does "it never completes" actually mean? Does it even prevent you from doing a Ctrl-C?
The script contains a recursive function. In case of programming error, it could loop forever and also use up all of the stack. But of course, you should still be able to do a Ctrl-C.

Neil Waldhauer:
If I catch it in time, I can ctrl-C to stop it. Otherwise only the power switch.

There are C language JSON interpreters, but it was so nice to have the REXX one.

The website at https://jsonformatter.curiousconcept.com/ says the file is valid JSON, and it shows that the file is really not that complex. There are just 11 items, one of which is an array.

Lars:
Maybe the easiest thing would be to wrap the C code with the REXX Interface. That will give you a good performance and still allow you to use it from REXX. But of course, you'll either need the C Source or a DLL to link to (with a published interface).

Lars:

--- Quote from: Neil Waldhauer on May 21, 2021, 08:54:07 pm ---If I catch it in time, I can ctrl-C to stop it. Otherwise only the power switch.

There are C language JSON interpreters, but it was so nice to have the REXX one.

The website at https://jsonformatter.curiousconcept.com/ says the file is valid JSON, and it shows that the file is really not that complex. There are just 11 items, one of which is an array.

--- End quote ---
I take it, the recursion never stops and eventually blows the stack. And then there seems to be a bug in the REXX interpreter to hang the whole system.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version