If I have ASP Classic, is it possible to build a REST-style application programming interface (API), that accepts input and returns output in JSON, or even does content negotiation and delivers the response in JSON or XML or some other format?
As an example, could ASP-Classic be used as a backing for a jQuery autocomplete widget that sends GET requests and expects JSON responses?
How?
Sure, why not?
First, you can program ASP-classic in Javascript. And, that means you can take advantage of the many Javascript extension libraries. In particular , when building a REST app, you might want to use json2.js.
This is a REST program that uses ASP-classic, queries a SQLExpress database using a parameterized query, and relying on json2.js for the encoding, returns a JSON-encoded array.
You can also use something like my aspJSON class: https://github.com/rcdmk/aspJSON
ASP is just very slight souped up Script engine. If you can code it it can do it. You can write whatever you like via
Response.Write
orResponse.BinaryWrite
. So the answer has to yes.If you are gonna do JSON you would be better of working in JScript server-side. You can then using standard JSON stringyfiers to generate JSON result.