JSON Web Services

I’ve recently learned that it is possible to create a web service which returns JavaScript Object Notation JSON rather than XML. ASP.NET 2.0 allows you to give a web service a ScriptService attribute which “AJAX enables” the Web Service and allows JSON (JavaScript Object Notation) objects to be returned instead of SOAP messages. The client JavaScript can even directly call the web service using a ASP.NET AJAX client-side proxy. ASP.NET 2.0 has a JavaScriptSerializer class which you can use to convert data into JSON.

This is proving to be very useful for a project I am working on which pulls a lot of data from a database to create JavaScript arrays. The JavaScript arrays are then used to populate drop down lists. Unfortunately, this web application has some performance issues because it requires the browser to keep too much data in its memory. I’m hoping to solve this problem by using AJAX to load the JavaScript arrays instead of dynamically creating them through browser code, i.e. JavaScript code. The browser will still be holding the data in memory but it will not need to parse quite so much JavaScript code.

I am currently very interested in JSON because it has proven to be essential to create AJAX applications which can work in compiled HTML help files and help collections. I have already added some fully functional applications to my Notes; a RSS reader, an IP address lookup page, a page to get the weather from the National Weather Service, and a page to get postage rates from USPS. Some of these widgets require a proxy service running on my local web server to make remote requests for XML which is then converted to JSON. Now I should be able to add some custom web services to my JSON data sources. Google and Yahoo also provide many web services which can provide data in the JSON format.

This entry was posted in ASP.NET, General, Programming. Bookmark the permalink.

Leave a Reply

Your email address will not be published.