Reputation: 16364
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?
Upvotes: 1
Views: 135
Reputation: 192587
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().
Upvotes: 0
Reputation: 4806
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.
Upvotes: 2