How to remove d: and __type from JSON response for ASP web service

前端 未结 3 923
别跟我提以往
别跟我提以往 2021-01-03 02:05

I\'ve found several solutions for this on the web that are for WCF web service and not ASP web service.

Currently, I\'m getting back a JSON response that says:

3条回答
  •  攒了一身酷
    2021-01-03 02:42

    I don't think that you can. I think that is the format of the json that is returned.

    You can try get rid of the ResponseFormat bit and return a string and use

    JavaScriptSerializer ser = new JavaScriptSerializer(); 
    string json = ser.Serialize(objectClass);
    return json;
    

    Or even better use the JSON.Net libraries.

    Also look at How to not serialize the __type property on JSON objects for how to remove the __type bit.

提交回复
热议问题