Removing the “d” object from ASP.Net web service json output

前端 未结 3 634
天涯浪人
天涯浪人 2020-12-17 03:37

I have some javascript code that processes json output from asp.net web services built with framework 2.0. Now I need to support data returned from framework 3.5 web service

3条回答
  •  [愿得一人]
    2020-12-17 04:16

    Here is a way around that

        [WebMethod]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public void Status()
        {
            MyObject myObject = new MyObject(); // your object here
            var json = Newtonsoft.Json.JsonConvert.SerializeObject(myObject);
    
            HttpContext.Current.Response.Write(json);
        }
    

提交回复
热议问题