Converting a Collection to a JScript Object in ASP

Comments

Some Classic ASP code snippets in JScript for dealing with form data.

Enumerators are collections of data that can be iterated through. Although useful, they are not compliant with ECMAScript standards, and therefore I prefer not to use them. Some objects in the ASP environment however, such as Request.Form, are provided as Enumerators, and need to be converted them to standard JScript objects. Here’s a couple of routines to do so.

Converting A Collection To A Plain JScript Object

I keep all the functions below in a generic include, coll2obj.asp, and use it across projects. This is a generic collection-to-object conversion, which doesn’t seem to work on some built-in collections.

Converting Request.ServerVariables To JScript Object In Classic ASP

I’m not quite sure why the function above won’t work on Request.ServerVariables, but it doesn’t, so here’s a function for that specific collection.

Converting Post Variables To JScript Object In Classic ASP

The same holds for post variables…

Converting Post Variables To JScript Object In Classic ASP

…and query string variables.

Comments