到畅移首页

调用获取成员接口,返回的json格式中文是乱码,如何处理乱码情况?

打印

微信企业号在使用过程中若遇到以上情况,可用以下代码尝试调试。

protected static string GetJson(string url)
        {
            try  
            {
                System.Net.ServicePointManager.Expect100Continue = false;
                WebClient wc = new WebClient();
                wc.Credentials = CredentialCache.DefaultCredentials;
                wc.Encoding = Encoding.UTF8;
                string returnText = wc.DownloadString(url);
                if (returnText.Contains("errcode"))
                {
                    //可能发生错误

                    System.Web.HttpContext.Current.Response.Write("
rn GetJson 过程错误!请稍后再登陆!
rn
"+returnText.ToString());

                }
                return returnText;
            }
            catch (Exception ex)
            {
                System.Web.HttpContext.Current.Response.Write("
rn GetJson 过程错误!请稍后再登陆!
rn
"+ex.ToString());

                return ex.ToString();
            }
        }



温馨提示:调试过程中出现疑问,可咨询畅移客服QQ:4008606961。