Generate JSON from VBScript (ASP) datatypes

When working with JSON it’s nice to have a generator for your language which transforms all the datatypes from your chosen programming language into the JSON grammar so that you can use them within javascript. For a lot of popular languages it’s done already (i suppose) but I haven’t found one for classic ASP .. so here it comes. The following example quickly demonstrates what the goal is:

  1. set RS = getRecordset("SELECT * FROM table")
  2. response.write((new JSON).toJSON("rows", RS))

A simple usage of JSON normally is that you create a page which outputs data as JSON as the only response. This page is called later from another page and the returned data is used within a javascript function (known as callback). So the snippet above gets some data from the database and stores it in an adodb.recordset which is passed then to the JSON generator and the result is printed on the page. The consuming page would like to access the data now as it originally was within the recordset. like this:

function callback(rows) {
for (i = 0; i < rows.length; i++) { alert(rows[i].columName); } } [/javascript] read on to get the details... Continue reading

JSON character escaping function in classic ASP

If you are into advanced AJAX techniques you probably will stumble across JSON ( which makes developing (and therefore the life) a lot easier when working with AJAX. If you already stumbled across and you use JSON within classic ASP you might find this article useful. It deals with escaping characters for JSON acording to the RFC4627#2.5 Continue reading

FormWalker – walking through form fields with the enter key

In conventional business applications users are used to navigate through form fields just by using the “enter” key rather than using the “tab” key. Especially on forms where they bung in a lot of numeric data (e.g. sales) it’s more common to use the numeric block (numlock) and therefore the “enter” key is more convenient to use … cause there is no tab key. I’ve just written a short javascript snippet which solves this problem. I call it FormWalking. Continue reading