views:

71

answers:

2

I wrote a web application using ASP .Net MVC. One of the application's function is to return a list of objects, using json, to the webpage. However these objects are of different types. How can I determine the types of these objects using javascript?

+2  A: 

There is no notion of object type in javascript. If you need that information for some kind of logic running client-side, then add a property returning type name to your objects, then check it in JS.

Michał Chaniewski
A: 

You can emit the type of the object within the json serialization on the ASP.NET / server side. But I guess you are using the standard json serializer, and I am not sure if it is tweakable to emit the output of instance.GetType().

Cheeso