当前位置: 首页 > news >正文

asp网站gzip压缩wordpress官方主题推荐

asp网站gzip压缩,wordpress官方主题推荐,网站建设 牛商网技术提供,要做个卖东西网站怎么做序列化是指将对象转换为可存储或传输的格式#xff0c;例如将对象转换为JSON字符串或字节流。反序列化则是将存储或传输的数据转换回对象的过程。这两个过程在数据持久化、数据交换以及与外部系统的通信中非常常见 把对象转换成josn字符串格式 这个过程就是序列化 josn字符…序列化是指将对象转换为可存储或传输的格式例如将对象转换为JSON字符串或字节流。反序列化则是将存储或传输的数据转换回对象的过程。这两个过程在数据持久化、数据交换以及与外部系统的通信中非常常见 把对象转换成josn字符串格式    这个过程就是序列化 josn字符串: 就是拥有固定格式的字符串 { name: 张三, age: 25, isStudent: true } 步骤: 1.在引用上右键 2.添加Nuget程序包 3.搜索json 4.点击下载Newtonsoft.json 5.在项目using  Newtonsoft.json 先声明两个类 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace 序列反序列.Models {[Serializable]//表示这个类可以序列化internal class User{public int Id { get; set; }public string Name { get; set; }public string Email { get; set; }public string Password { get; set; }} }using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace 序列反序列.Models {internal class Product{public int Id { get; set; }public string Name { get; set; }public string Description { get; set; }public float Price { get; set; }public User SaleUser { get; set; }} }using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using 序列反序列.Models; using Newtonsoft.Json;namespace 序列反序列 {/// summary/// MainWindow.xaml 的交互逻辑/// /summarypublic partial class MainWindow : Window{public MainWindow(){InitializeComponent();}string sstring.Empty;private void button1_Click(object sender, RoutedEventArgs e){Console.ForegroundColor ConsoleColor.Red;User user new User() { Id 1 , Name 小张 ,Email163.com,Password123566};sJsonConvert.SerializeObject(user);Console.WriteLine(s);Console.WriteLine(这上面是序列化的);}private void Button_Click(object sender, RoutedEventArgs e){if (!string.IsNullOrWhiteSpace(s)){User newUser JsonConvert.DeserializeObjectUser(s);Console.WriteLine(newUser.Name);}else{Console.WriteLine(先序列化);}}} }序列化 Console.ForegroundColor ConsoleColor.Red;User user new User() { Id 1 , Name 小张 ,Email163.com,Password123566};sJsonConvert.SerializeObject(user);Console.WriteLine(s);Console.WriteLine(这上面是序列化的); 反序列化 if (!string.IsNullOrWhiteSpace(s)){User newUser JsonConvert.DeserializeObjectUser(s);Console.WriteLine(newUser.Name);}else{Console.WriteLine(先序列化);} 效果 对象嵌套序列化 Product product new Product() {Id 1,Name 小明,Description 小明有一个狗,Price 1000.123f,SaleUser new User { Name 小兰, Id 2 } };string s JsonConvert.SerializeObject(product, Formatting.Indented); Console.WriteLine(s); Product product1 JsonConvert.DeserializeObjectProduct(s); Console.WriteLine(product1.Name); Console.WriteLine(product1.SaleUser.Name); 数组序列化 User user1 new User(){Id 1,Name 小丑,Email 168qq.com,Password 1452};User user2 new User() { Id 2, Name 效率, Email 9999qq.com, Password 246810 };object[] objs { user1, user2, true, 不知道 };s2 JsonConvert.SerializeObject(objs, Formatting.Indented);Console.WriteLine(s2); 数组反序列化 if (!string.IsNullOrWhiteSpace(s2)){object[] objs JsonConvert.DeserializeObjectobject[](s2);Console.WriteLine(objs[1]);//字符串User u JsonConvert.DeserializeObjectUser(objs[1].ToString());Console.WriteLine(u.Name);} 效果
http://www.dnsts.com.cn/news/99211.html

相关文章:

  • aspcms网站地图wordpress助手网
  • seo导航站网站开发组
  • 企业门户网站开发要多少钱wordpress主题在那个文件夹
  • 做奢侈品的网站网站虚假备案
  • 网页设计中文本居中用什么代码专注网站基础优化
  • 西宁北京网站建设网页视频制作软件
  • 网站前端设计理念建设网站好学吗
  • 郑州企业建站网站昆明网站建设推广服务
  • 咨询北京国互网网站建设二手车辆交易网站如何做
  • 北京品牌网站设计潮州网站设计
  • 导购网站制作土巴兔全包装修怎么样
  • 秦皇岛seo免费seo营销优化软件下载
  • 网站建设的岗位职责网站建设工作内容
  • sql数据库环境网站搭建教程南京网站制作建设
  • 用rp怎么做网站按钮下拉菜单广州网站建设功能
  • 花卉电子商务网站开发国内优秀企业网站
  • 用网站做数据库吗wordpress自定义文章
  • 发布设计任务的网站网上卖货平台有哪些
  • 建购物网站如何运营做网站的财务会涉及到的科目
  • 学做网站需要学哪些软件宁津县建设局网站
  • 网站内链怎么做更好网站管理公司排名
  • 网站开发人员的岗位职责网站前端设计公司
  • 怎么利用QQ空间给网站做排名免费wordpress主题破解版
  • 适合vue做的网站类型如何能查到百度搜索排名
  • 做任务领佣金的网站源码佛山做企业网站公司
  • 南昌网站建设和推广微信企业邮箱
  • 淘宝做网站seo推广主管
  • 网站开发有很多种吗网站域名不要了怎么做
  • 网站设计方案谁写南宁网站建设怎么样
  • 在哪里可以接网站开发的外包深圳企业品牌网站