json 转换汇总
来源:互联网 发布:cdn用什么软件linux 编辑:程序博客网 时间:2024/05/29 16:55
Newtonsoft.Json.dll 引用dll
http://blog.csdn.net/a5251199/article/details/49797389?locationNum=2&fps=1 发送和接收
---------------------------------------------------------------c#---------------------------
Product product = new Product();
product.Name = "Apple";
product.Expiry = new DateTime(2008, 12, 28);
product.Price = 3.99M;
product.Sizes = new string[] { "Small", "Medium", "Large" };
序列化
string output = JavaScriptConvert.SerializeObject(product);
//{
// "Name": "Apple",
// "Expiry": new Date(1230422400000),
// "Price": 3.99,
// "Sizes": [
// "Small",
// "Medium",
// "Large"
// ]
//}
----------------------------c#--------------------------反序列化---------------------------
Product deserializedProduct = (Product)JavaScriptConvert.DeserializeObject(output, typeof(Product));
-----------------------------------jq-----------------------------序列化和反序列化---------------------------------
var postdata = { ID: "1", NAME: "Jim", CREATETIME: "1988-09-11" };
$.ajax({
type: "post",
url: "http://localhost:27221/api/Charging/SaveData",
contentType: 'application/json',
data: JSON.stringify({ NAME:"Lilei", Charging:postdata }),
success: function (data, status) {}
});
-------------------------反序列化-------------------jq------------------
var serval="a=1&b=2&c=3";var arrval=serval.split('&');//将字符串分割成数组,即 a=1,b=2,c=3的形式for(var i=0,l=arrval.length;i<l;i++){ var tmp=arrval[i].split('='); $("#"+tmp[0]).val(tmp[1]);}
-----------------------------------------------------------------get 授权--------------------------
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:25017/api/Member/GetAllChargingData");
request.Method = "GET";
request.Headers.Add("Authorization", "BasicAuth " + Ticket);
request.ContentType = "text/html;charset=UTF-8";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream myResponseStream = response.GetResponseStream();
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8);
string retString = myStreamReader.ReadToEnd();
myStreamReader.Close();
myResponseStream.Close();
- json 转换汇总
- JSON 转换
- JSON转换
- json 转换
- JSON转换
- json转换
- Json转换
- Json转换
- JSON 转换
- JSON转换
- json转换
- json转换
- Json转换
- Json 转换
- Json转换
- json转换
- json转换
- json转换
- 输入一个链表,从尾到头打印链表每个节点的值
- 垃圾图论题
- 有关javascript的作用域问题
- Nginx代理服务器反向代理
- hadoop的单机环境搭建
- json 转换汇总
- 数据库中存储过程有什么主要作用,或都说它的主要用途?
- Spring AOP——在通知(Advice)方法中获取目标方法的参数
- IPC信号量 sem
- mysql自动备份脚本
- Samba 学习第二章 操作用户
- Android自定义组件学习笔记(1)---仿网页进度条
- WindowsMessage
- Source Insight配置