views:

55

answers:

1

In most cases we are using ASP.NET web services (System.Web.Script.Services.ScriptService) in our AJAX based web applications. This approach brings a major advantage providing automatically all the server-side classes (used in the web service methods) on client side in form of JavaScript alternatives (javascript classes with appropriate namespace).

However, in our applications we are working with classed based on 3rd party framework classes. It means this classes inheriting many unserializable properties what makes them unusable for the automatic web service serialization into JSON and back once sent to the client side.

The question is, if there is a way how to define the list of properites we would like to serialize to JSON and back (once send to client and back) for apropriate class.

Thank you for any clue.

A: 

There are two approaches I can think of:

  1. Wrap your 3rd party classes in your own classes where you can control what properties get exposed to the serializer. This has the benefit that it should allow you to expose the data with any web service implementation (e.g. JSON, XML).

  2. Create a JavaScriptConverter class that will let you implement custom serialization and deserialization of the third party classes.

Tuzo