using System.Web.Script.Serialization;

/// <summary> /// 内部类,保存jsonData /// </summary> public class JsonData { private string _userName; private string _userPassword; public bool IsStoreUserName { get; set; } public bool IsStoreUserPassword { get; set; } public string UserName { get { return IsStoreUserName ? _userName : ""; } set { _userName = IsStoreUserName ? value : ""; } } public string UserPassword { get { return IsStoreUserPassword ? _userPassword : ""; } set { _userPassword = IsStoreUserPassword ? value : ""; } } } #region JsonToObject json与类互转 // Object->Json public static string Serialize(JsonData obj) { JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); string json = jsonSerializer.Serialize(obj); return json; } // Json->Object public static JsonData Deserialize(string json) { JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); JsonData obj = jsonSerializer.Deserialize<JsonData>(json);//执行反序列化 return obj; } #endregion JsonToObject json与类互转

 

相关文章:

  • 2022-12-23
  • 2022-01-20
  • 2022-12-23
  • 2021-10-19
  • 2021-08-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-10-22
  • 2021-07-02
  • 2022-12-23
相关资源
相似解决方案