环境说明:Silverlight 5.1,.Net Framework 4.0 1.添加引用System.ServiceModel.Web.dll. 因为 System.Runtime.Serialization.Json.DataContractJsonSerializer 类的引用是在System.ServiceModel.Web.dll这个程序集中. 2.代码如下 using System; using System.Collections.Generic; using System.…
var response = await httpClient.PostAsync(endpoint, new FormUrlEncodedContent(parameters)); var result = await response.Content.ReadAsStreamAsync(); var reader = new StreamReader(result); var str = reader.ReadToEnd(); //if (response.Content != null &…
项目引用 System.Runtime.Serialization.dll 添加命名空间 using System.Runtime.Serialization.Json; 1.序列化对象,得到Json字符串 public static string WriteFromObject<T>(T obj) where T : class { DataContractJsonSerializer dcjs = new DataContractJsonSerializer(typeof(T)); usi…
定义一个下面这样的类,此类有Serializable属性,并且有一个属性的定义没有使用自动属性来实现. [Serializable] public class Users { public int UserID { get; set; } public string UserName { get; set; } public string UserEmail { get; set; } private string _testProperty; public string TestPropert…