Json.Net 3.0应用:asp.net 3.5 操作Json数据
2008-10-07 16:48
645 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Json应用
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Product1 product = new Product1();
product.name = "sdfsdfwwwwww";
product.Expiry = new DateTime(2008, 12, 28);
product.price = 3;
product.Sizes = new string[] { "123", "123", "123" };
Product o = new Product();
o.name = "sdwwfsdf";
o.Expiry = new DateTime(2008, 12, 28);
o.price = 3;
o.Sizes = new string[] { "sdfsdf", "123", "123123" };
o.Product1 = product;
string json = Newtonsoft.Json.JavaScriptConvert.SerializeObject(o);
//Response.Write(json);
Product oProduct = Newtonsoft.Json.JavaScriptConvert.DeserializeObject<Product>(json);
this.Response.Write(oProduct.name);
}
}
public class Product
{
public string name
{
get;
set;
}
public DateTime Expiry
{
get;
set;
}
public float price
{
get;
set;
}
public string[] Sizes
{
get;
set;
}
public Product1 Product1
{
get;
set;
}
}
public class Product1
{
public string name
{
get;
set;
}
public DateTime Expiry
{
get;
set;
}
public float price
{
get;
set;
}
public string[] Sizes
{
get;
set;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Json应用
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Product1 product = new Product1();
product.name = "sdfsdfwwwwww";
product.Expiry = new DateTime(2008, 12, 28);
product.price = 3;
product.Sizes = new string[] { "123", "123", "123" };
Product o = new Product();
o.name = "sdwwfsdf";
o.Expiry = new DateTime(2008, 12, 28);
o.price = 3;
o.Sizes = new string[] { "sdfsdf", "123", "123123" };
o.Product1 = product;
string json = Newtonsoft.Json.JavaScriptConvert.SerializeObject(o);
//Response.Write(json);
Product oProduct = Newtonsoft.Json.JavaScriptConvert.DeserializeObject<Product>(json);
this.Response.Write(oProduct.name);
}
}
public class Product
{
public string name
{
get;
set;
}
public DateTime Expiry
{
get;
set;
}
public float price
{
get;
set;
}
public string[] Sizes
{
get;
set;
}
public Product1 Product1
{
get;
set;
}
}
public class Product1
{
public string name
{
get;
set;
}
public DateTime Expiry
{
get;
set;
}
public float price
{
get;
set;
}
public string[] Sizes
{
get;
set;
}
}
}
相关文章推荐
- Asp.net中Json数据的转化,读取与应用
- asp.net mvc 3.0详细笔记__09__创建数据库,应用EF连接模型类和数据表
- ASP.NET MVC WebApi 返回数据类型序列化控制(json,xml) 用javascript在客户端删除某一个cookie键值对 input点击链接另一个页面,各种操作。 C# 往线程里传参数的方法总结 TCP/IP 协议 用C#+Selenium+ChromeDriver 生成我的咕咚跑步路线地图 (转)值得学习百度开源70+项目
- 基于ASP.NET 3.5 Web Service 的JSON扩展应用
- 基于ASP.NET 3.5 Web Service 的JSON扩展应用 推荐
- Asp.net中Json数据的转化,读取与应用
- Asp.net中Json数据的转化,读取与应用
- jquery+asp.net操作json数据的示例
- 在ASP.NET MVC中json的应用(即JsonResult)(asp.net mvc 后台返回json数据方式 )
- Newtonsoft.Json 为asp.net 3.5开发的
- xml json两种数据格式后台的封装(asp.net)
- 在ASP.NET 2.0中操作数据之二十六:排序自定义分页数据
- ASP.NET前后台交互之JSON数据
- asp.net中使用jQuery调用WebService返回JSON数据
- Asp.Net使用org.in2bits.MyXls.dll操作excel的应用 (转)
- 在ASP.NET 2.0中操作数据之三十二:数据控件的嵌套
- 在ASP.NET 2.0中操作数据之三十:格式化DataList和Repeater的数据
- 【Asp.net入门3-05】处理JSON数据
- 在ASP.NET 2.0中操作数据之三十五:使用Repeater和DataList单页面实现主/从报表
- [翻译]在Asp.net 2.0中操作数据::母板页和站点导航