Mail/Login: Password : forgot my password!

Uniface web tools - uList2json

Direct link
Written by M11 // Tags: entry list json tool

Version 1:
Here come a little tool that transforms your simply Uniface associative list into a JSON string.
The basic idea behind this is just to make your list accessable in an easy way for your server page. First of all, let me show you the code.
Uniface entry SOURCE CODE
Sorry- ... please log-in or register to get this!

Notes on this code

This code is surely not the final cast. Take care of the valueparts, as the could need to get quoted in order not to destroy the JSON structure.
Further the code could be used recursively if somebody would like to take hands on that.


A code is a code, but it gains more acceptance with an example. We will take a little case on this. Straight from my development here, the scenario is that a server page (the HTML in the browser) expects data in a JSON string (delivered by Uniface). But as the Uniface code encounters an error while running through the statements, we will deliver a failure notice to the requesting page. Take a look
Uniface proc code SOURCE CODE
Sorry- ... please log-in or register to get this!

Inside the HTML (in the server page) we can evaluate the result very easy and display the needed feedback for the user. Every IDpart of our Uniface list can now be accessed with JavaScript. The Code below will demonstrate a typical AJAX request, where JSON is the returned format.

If the request inside of Uniface succeeds, the screen will show the value of the Result. Otherwise an Error will be shown, where $status and the returned message is shown.
JavaScript code SOURCE CODE
Sorry- ... please log-in or register to get this!

You'll will find more about JSON at

If you have improvements or suggests on this tool, just let me know and we will update this.

Update: one proc fitting all needs!

M11 did some stuff on the code aswell as RichardGill. I wont hold that back from you so here comes M11's Extension.


-Recursive Code generation
-detects alpha and numeric values

Version 2:
Uniface entry SOURCE CODE
Sorry- ... please log-in or register to get this!

Tell us, how you like that!


on 2011-03-15 01:21:45 RichardGill wrote:

I agree GHAN, escaping should be done outside the json generation, because its language string handling specific (and escaping may not be wanted in javascript, for eval purpose)

on 2011-02-08 18:00:16 -GHAN- wrote:

Hmm ... how would you escape those charackters in Uniface? ... within JavaScript a \ is pretty fine. So in order to escape the stuff you send, $replace them to something with a leading \. Did this help you?

on 2011-02-07 17:47:15 FrankSjoukes wrote:

I am missing the escapes for special characters. Frank

on 2010-08-08 14:51:31 -GHAN- wrote:

sure... just handle it to me, so we can append this part

on 2010-07-30 11:18:29 RichardGill wrote:

I have an improved version with recursion and using lists as follow: * indexed => array * associative => object Thus, with recursion, you can make arrays of objects, which contain arrays, etc.. Tell me if youre interested.

2770 view(s) / 2010-07-23 09:05:55 / LAST UPDATED: 2011-03-11 16:20:24