zoukankan      html  css  js  c++  java
  • [No00009A]JsonToObject json与类互转

    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与类互转
  • 相关阅读:
    kubernetes yaml文件格式
    docker 镜像上传至私有仓库
    Docker Compose编排容器
    jenkins+gitlab+ansible+dockerfile+k8s自动发布代码
    kubernetes 命令行
    关于HDFS的读写流程
    vue中watched属性
    app中rem算法
    vue使用中的随笔
    react 表单获取多个input
  • 原文地址:https://www.cnblogs.com/Chary/p/No00009A.html
Copyright © 2011-2022 走看看