0

我正在以 Web 角色序列化云服务器中的对象:

using Newtonsoft.Json;    
string returnJsonMessage = JsonConvert.SerializeObject(returnMessage);

在客户端:

BaseResponseDeviceMessage retVal = null;
        var req = HttpWebRequest.Create(@reqString);
        req.Method = requestMethod;
        req.ContentLength = 0;
        req.ContentType = @"application/json";

        string jsonResp = "";
        try
        {
            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
            using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
            {
                jsonResp = sr.ReadToEnd();
            }

            string t = JsonConvert.DeserializeObject<string>(jsonResp);
            retVal = JsonConvert.DeserializeObject<T>(t);

        }

您可以看到,为了取回我的消息,我需要 DeSerialize 两次。为什么?如何解决这个问题?谢谢大家,祝你有美好的一天。

4

0 回答 0