资源简介
Json的使用Demo,交你如何封装和解析使用Json,一看就懂,简单实用
代码片段和文件信息
using System;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Windows.Forms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.script.Serialization;
namespace Demo_Json
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender EventArgs e)
{
Person p = new Person();
p.ID = 1;
p.Name = “大神“;
p.Age = 28;
p.BirthDay = DateTime.Now.AddYears(-28);
var json = new javascriptSerializer() { MaxJsonLength = int.MaxValue };
string Encode = json.Serialize(p);
Person Decode = json.Deserialize>(Encode);
}
private void button2_Click(object sender System.EventArgs e)
{
List> people = new List>();
for (int i = 0; i < 5; i++)
{
Person tempP = new Person();
tempP.Content = new List();
tempP.ID = i + 1;
tempP.Name = “Keal“ + i + 1;
tempP.Age = i + 20;
tempP.BirthDay = DateTime.Now.AddYears(-20 - i);
DogInfo dogLing = new DogInfo();
dogLing.Name = “LingLing“;
dogLing.Owner = “keal“;
tempP.Content.Add(dogLing);
DogInfo dogHui = new DogInfo();
dogHui.Name = “HuiHui“;
dogHui.Owner = “keal“;
tempP.Content.Add(dogHui);
DogInfo dogLa = new DogInfo();
dogLa.Name = “LaLa“;
dogLa.Owner = “val“;
tempP.Content.Add(dogLa);
people.Add(tempP);
}
var json = new javascriptSerializer() {MaxJsonLength = int.MaxValue};
string Encode = json.Serialize(people);
List> DogDecode = json.Deserialize>>(Encode);
List> CatDecode = json.Deserialize>>(Encode);
}
}
public class Person
{
public int ID { get; set;}
public string Name { get; set; }
public int Age { get; set; }
public DateTime BirthDay { get; set; }
public List Content { get; set; }
}
public class DogInfo
{
public string Name { get; set; }
public string Owner { get; set; }
}
public class CatInfo
{
public string Name { get; set; }
public string Owner { get; set; }
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 917 2013-07-18 14:10 Demo_Json\Demo_Json.sln
文件 53760 2013-08-29 11:11 Demo_Json\Demo_Json.v11.suo
目录 0 2013-08-29 15:35 Demo_Json\Demo_Json\
文件 167 2013-07-18 14:28 Demo_Json\Demo_Json\App.config
目录 0 2013-08-29 15:35 Demo_Json\Demo_Json\bin\
目录 0 2013-08-29 15:35 Demo_Json\Demo_Json\bin\Debug\
文件 11264 2013-08-29 10:13 Demo_Json\Demo_Json\bin\Debug\Demo_Json.exe
文件 167 2013-07-18 14:28 Demo_Json\Demo_Json\bin\Debug\Demo_Json.exe.config
文件 30208 2013-08-29 10:13 Demo_Json\Demo_Json\bin\Debug\Demo_Json.pdb
文件 22472 2013-08-29 10:14 Demo_Json\Demo_Json\bin\Debug\Demo_Json.vshost.exe
文件 167 2013-07-18 14:28 Demo_Json\Demo_Json\bin\Debug\Demo_Json.vshost.exe.config
文件 490 2012-06-06 02:06 Demo_Json\Demo_Json\bin\Debug\Demo_Json.vshost.exe.manifest
文件 4375 2013-07-18 15:31 Demo_Json\Demo_Json\Demo_Json.csproj
文件 2842 2013-08-29 10:00 Demo_Json\Demo_Json\Form1.cs
文件 2823 2013-07-18 16:03 Demo_Json\Demo_Json\Form1.Designer.cs
文件 5817 2013-07-18 16:04 Demo_Json\Demo_Json\Form1.resx
目录 0 2013-08-29 15:35 Demo_Json\Demo_Json\obj\
目录 0 2013-08-29 15:35 Demo_Json\Demo_Json\obj\Debug\
文件 1632 2013-08-29 10:14 Demo_Json\Demo_Json\obj\Debug\Demo_Json.csproj.FileListAbsolute.txt
文件 975 2013-08-29 09:51 Demo_Json\Demo_Json\obj\Debug\Demo_Json.csproj.GenerateResource.Cache
文件 2992 2013-08-29 09:51 Demo_Json\Demo_Json\obj\Debug\Demo_Json.csprojResolveAssemblyReference.cache
文件 11264 2013-08-29 10:13 Demo_Json\Demo_Json\obj\Debug\Demo_Json.exe
文件 180 2013-08-29 09:51 Demo_Json\Demo_Json\obj\Debug\Demo_Json.Form1.resources
文件 30208 2013-08-29 10:13 Demo_Json\Demo_Json\obj\Debug\Demo_Json.pdb
文件 180 2013-08-29 09:51 Demo_Json\Demo_Json\obj\Debug\Demo_Json.Properties.Resources.resources
文件 1686 2013-07-18 14:54 Demo_Json\Demo_Json\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7516 2013-08-29 10:12 Demo_Json\Demo_Json\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 0 2013-07-18 14:10 Demo_Json\Demo_Json\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
文件 0 2013-07-18 14:10 Demo_Json\Demo_Json\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
文件 0 2013-07-18 14:10 Demo_Json\Demo_Json\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
目录 0 2013-08-29 15:35 Demo_Json\Demo_Json\obj\Debug\TempPE\
............此处省略9个文件信息
相关资源
- Newtonsoft.Json dll
- C# MVC 封装百度的EChart完整
- C#Json文件读写修改类附带操作程序.
-
Json、xm
l、CSV数据互转工具 - ASP.NET MVC5考试_管理系统源码
- ASP.NET MVC Json表格数据 为Excel
-
(C#)json to xm
l 解析转换源代码 - C# Winform Sockets收发Json样例
- C#后台返回json类型数据
- c#下post multipart/form-data和JSON
- 在asp.net中使用JqueryAjaxJson实现无刷新
- LitJson开发包
- C#将json格式转换成DataTable
- C#开发webservice接口,对客户端post服务
- C# 操作解析Json源码
-
c# JSon
helper 工具类 - C#,AJAX读写JSON
- C# Json转换DataTable源文件
- Newtonsoft
- json读写类
- WinCE访问WebAPI及Json切换功能
- C#窗口实现百度云人脸识别
- LitJson.dll C# 与 unity 可用的Json处理插
- JSON.NET源码
- c# 校验文本是否为合法json格式
- fastJSON.dll
- C#实现PDF的自主生成
- C#Newtonsoft.json类库
- 全国省市县镇村数据Json
- Json文件一键转Excel
评论
共有 条评论