标签:序列化与反序列化
代码:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Newtonsoft.Json;//引用命名空间 namespace ConsoleApplication3 { class Program { static void Main(string[] args) { Serializer(); Deserialize(); Console.ReadKey(); } //序列化 private static void Serializer() { Dictionary<string, string> dic = new Dictionary<string, string>(); dic["ProvinceSysNo"] = "19"; var str = JsonConvert.SerializeObject(dic); Console.WriteLine(str); } //反序列化 private static void Deserialize() { string json = "{\"ProvinceSysNo\":\"19\"}"; var dic = JsonConvert.DeserializeObject<Dictionary<string, object>>(json); foreach (var s in dic) { Console.WriteLine("key:{0},value:{1}", s.Key, s.Value); } } } }
下载地址:http://pan.baidu.com/s/1jGxkCjs
本文出自 “程序猿的家--Hunter” 博客,请务必保留此出处http://962410314.blog.51cto.com/7563109/1669810
标签:序列化与反序列化
原文地址:http://962410314.blog.51cto.com/7563109/1669810