Has anyone written a jsonParse or fromJson method/library they wish to share?

Why? I moved part of an application from 4D to RoR and need to set up a private web service in Active4D to talk to RoR. json is also a neat way of serializing a collection (that has nested collections) for storage.

I created one several years ago based on a javascript port of <http://www.json.org/json_parse.js > to Active4D. It works and creates a collection - not the prettiest code in the world, but it even handled arrays with different types - converting them to a collection with a string index collection.

I was just wondering if there was an "official" one out there. I thought about rewriting it using the state version <http://www.json.org/json_parse_state.js > and integrating it with a4d.json.a4l. That came to a halt when I found out that Active4d's Regex implementation must be different then javascripts. As a test, I tried this:

$tx := '!^[\x20\t\n\r]*(?:([,:\[\]{}]|true|false|null)|(-?\d+(?:\.\d*)? (?:[eE][+\-]?\d+)?)|"((?:[^\r\n\t\\\"]|\\(?:["\\\/trnfb]|u[0-9a-fA-F] {4}))*)")!'
$myJSONObject := """{"bindings": [
{"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"}, {"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"}, {"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"}
    ]   """

$cnt := regex match($tx;$myJSONObject;$results)

but Active4D balked at character 126 saying a missing paren. I'm not event going begin to try to understand that regexp!

Steve Alex

P.S. I'll share my version if there is not an official one out there.
_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/

Reply via email to