json.net简明教程
来源:互联网 发布:淘宝管控记录什么意思 编辑:程序博客网 时间:2024/06/07 10:34
json.net的使用起来很简单的
可以到它的官方网站去下载它的组件(注意版本问题哦)
http://www.codeplex.com/Json/Release/ProjectReleases.aspx?ReleaseId=18825
安装后 引用
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Newtonsoft.Json;
using System.Collections;
using Newtonsoft.Json.Utilities;
using System.Runtime.Serialization;
using System.Text;
using System.Collections.Generic;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
public static string str = "hello";
protected void Page_Load(object sender, EventArgs e)
{
//第一种
BaseClass bs = new BaseClass();
bs.Title = "hello world";
bs.Content = "this is ok";
bs.Userip = "127.0.0.1";
//第二种
Hashtable hs1 = new Hashtable();
hs1.Add("username", "dwqdq");
hs1.Add("pwd", "656");
string json1 = JavaScriptConvert.SerializeObject(bs);
string json2 = JavaScriptConvert.SerializeObject(hs1);
Response.Write(json1);
Response.Write(json2);
}
}
BaseClass.cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// BaseClass 的摘要说明
/// </summary>
public class BaseClass
{
public BaseClass()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
string _title;
public string Title
{
get { return _title; }
set { _title = value; }
}
string _content;
public string Content
{
get { return _content; }
set { _content = value; }
}
string _userip;
public string Userip
{
get { return _userip; }
set { _userip = value; }
}
}
是不是很简单?
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/wangjun8868/archive/2008/11/19/3334690.aspx
- json.net简明教程
- .net处理JSON简明教程
- json-simple简明教程
- json使用简明教程及boost_property_tree
- 使用VS.NET开发Web Services 简明教程
- 使用VS.NET开发Web Services 简明教程
- 使用VS.NET开发Web Services 简明教程
- 【.Net码农】【Autofac】AutoMapper简明教程(学习笔记)
- SQL教程简明教程
- JSON简明介绍
- JSON.NET对象序列化示例教程
- Json.Net系列教程 4.Linq To JSON
- 简明批处理教程
- 简明批处理教程
- 简明批处理教程
- 简明批处理教程(.bat)
- PySqlite简明教程
- Forth语言简明教程
- android layout 研究 转载
- 优备数据备份软件与UPM技术对比
- 智能提示 模仿google
- 遍历题库管理系统中的枝枝叶叶
- 设置Domain Service传输给datagrid的记录条数的方法等。。
- json.net简明教程
- 关于VS2005中GridView的自定义分页,单选、多选、排序、自增列的简单应用
- 对stdin,stdout 和STDOUT_FILENO,STDIN_FILENO的学习
- JDK1.7的性能
- C语言算法速查手册
- CE SD卡驱动开发(Zylonite)(转)
- JAVA
- 2440从sd卡启动wince
- PHP 制作通讯录(一)