I have the following method:
using System.Web.Services;
using System.Web.Script.Services;
using System.Web.Script.Serialization;
using Newtonsoft.Json;
using
Sometimes we don't have access to make changes in WebService definition and sometimes we should not make changes in WebServices! so the best solution is set contentType="application/json; charset=..." in your request. just this!
For example you can use below code (if you are using jquery) instead of changing somethings in WebService:
$.ajax({
type: "POST",
url: '/ServiceName.asmx/WebMethodName',
date: {},
contentType: "application/json; charset=utf-8",
success: function (data) {
// Some code;
}
});
Then you can use JSON.parse(data.d) to access json structure of your data.