I'm using a .net script service which is called from client-side script, and it works very nicely.
only problem is- it generates a '__type' attribute for each of the returned objects, which I don't want or need.
I've seen a few posts about this over the web, and as far as I could tell, there are only 'workarounds' for this:
some people suggested hiding the parameter-less c'tor of the return type as 'internal protected',
others suggested not using the [ScriptMethod] tag, and instead JSONfy the result manually and return a string.
I'm wondering whether there is another, better, solution for this. and by the way- what is this attribute used for, anyway?
I'm enclosing the service method and the generated JSON.
method:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
public IEnumerable<EmployeePO> GetEmployeesForDepartment(int DepartmentId)
{
return new AdministrationController().GetEmployeesForDepartment(DepartmentId);
}
JSON returned:
{"d":[{"__type":"Application.Controllers.PresentationObjects.EmployeePO","Positions":[{"__type":"Application.Controllers.PresentationObjects.PositionPO","Id":4,"Name":"Employee: 1test Position 1","IsPriority":false,"WarningThreshold":50,"CriticalThreshold":60,"CurrentWaitingTime":-1,"Passengers":[],"Qualifications":[...