ASP.net解析JSON
using System;
using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.Script.Serialization; //导入解析Json的类public partial class _Default : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { string JSON = "{'info':[{'title':'list1','url':'/upload/209/20120814163339890.png'},{'title':'离职申请表','url':'/upload/209/20120814163339968.xls'},{'title':'申请表','url':'/upload/209/20120814163340046.doc'},{'title':'室内','url':'/upload/209/20120814163340156.jpg'},{'title':'心电图','url':'/upload/209/20120814163340218.gif'},{'title':'新建 文本文档','url':'/upload/209/20120814163340281.txt'}]}"; JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary<string, object> json = (Dictionary<string, object>)serializer.DeserializeObject(JSON); object[] info = (object[])json["info"]; Dictionary<string, object> val; Dictionary<int, string> Objs = null; Dictionary<int, string> fileOldName = null; for (int i = 0; i < info.Length; i++) { val = (Dictionary<string, object>)info[i]; foreach (KeyValuePair<string, object> str in val) { //保存信息到 session if (Session["bigfile_info"] == null) { Objs = new Dictionary<int, string>(); Session["bigfile_info"] = Objs; } if (Session["file_name"] == null) { fileOldName = new Dictionary<int, string>(); Session["file_name"] = fileOldName; } if (str.Key.Equals("title")) { fileOldName[i + 1] = str.Value.ToString(); } if (str.Key.Equals("url")) { Objs[i + 1] = str.Value.ToString(); } } } Session["bigfile_info"] = Objs; Session["file_name"] = fileOldName; if (Session["file_name"] != null) { Objs = (Dictionary<int, string>)Session["file_name"]; foreach (int i in Objs.Keys) { lblJson.Text += Objs[i]; } } }}ASP.net解析JSON的更多相关文章
- ASP.net解析JSON例子
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- Asp.net 解析json
Asp.net Json数据解析的一种思路 http://www.cnblogs.com/scy251147/p/3317366.html http://tools.wx6.org/json2csha ...
- Asp.Net解析json字符串
方法一: using LitJson; string json= "{...........}"; JsonData jdData = JsonMapper.ToObject(js ...
- ASP( VBScript ) 解析 JSON
<script language="jscript" runat="server"> Array.prototype.get = function( ...
- ASP.NET与json对象互转
这两天写这个xml跟json的读写,心累啊,也不是很理解,请大家多指教 首先来个热身菜做一个简单的解析json 在script里写一个简单的弹窗效果 <script> //script里简 ...
- ASP.NET 使用 System.Web.Script.Serialization 解析 JSON (转)
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.易于人阅读和编写.同时也易于机器解析和生成.它基于JavaScript Programming Langu ...
- asp.net中json格式化及在js中解析json
类: public class UploadDocumentItem { public UploadDocumentItem() { } public string DocMuid { get; se ...
- 《项目经验》--通过js获取前台数据向一般处理程序传递Json数据,并解析Json数据,将前台传来的Json数据写入数据库表中
先看一下我要实现的功能界面: 这个界面的功能在图中已有展现,课程分配(教师教授哪门课程)在之前的页面中已做好.这个页面主要实现的是授课,即给老师教授的课程分配学生.此页面实现功能的步骤已在页面 ...
- 使用 dynamic 标记解析JSON字符串 JDynamic :支持Json反序列化为Dynamic对象
使用 dynamic 标记解析JSON字符串 http://www.cnblogs.com/taotaodetuer/p/4171327.html 1 string jsonStr = " ...
随机推荐
- 序列式容器————dequeue
#include <deque> 双端队列,可以在队头队尾进行入队出队操作 deque<int> q; q.empty(); q.push_front(s);//将s插入到队头 ...
- BZOJ 3143 Luogu P3232 [HNOI2013]游走 (DP、高斯消元)
题目链接: (bzoj) https://www.lydsy.com/JudgeOnline/problem.php?id=3143 (luogu) https://www.luogu.org/pro ...
- java web程序上传文件,浏览器显示连接被重置
上传文件时,到13%时浏览器显示连接被重置如图: 参考网上很多方法 比如设置server.xml 的相应大小.时间,然并没有解决问题 connectionTimeout="2000000&q ...
- [CSP-S模拟测试]:bird(线段树优化DP)
题目传送门(内部题89) 输入格式 第一行两个数$n$和$k$,分别表示小鸟的只数和$R$装弹时间.接下来$n$行,每行两个数$l,r$表示$n$只小鸟初始时的头和尾的$x$坐标. 输出格式 输出一个 ...
- Springboot application 本地HTTPS配置
使用keytool 命令,生成一个数字证书: keytool -genkey -alias tomcathttps -keyalg RSA -keysize 2048 -keystore key.p1 ...
- Vue中 v-bind和v-on 缩写
v-bind 缩写 <!-- 完整语法 --> <a v-bind:href="url">...</a> <!-- 缩写 --> & ...
- Getting CFNetwork SSLHandshake failed (-9806) error
平常个人打测试包一切OK,今天突然不能联网了 How to handle "CFNetwork SSLHandshake failed" in iOS 参考1 Getting CF ...
- LINK : fatal error LNK1104: 无法打开文件“qtmaind.lib”
LINK : fatal error LNK1104: 无法打开文件"qtmaind.lib" VS2019+QT5.13出现该问题,可以尝试这样解决. 1.找打qtmaind.l ...
- 【Spark机器学习速成宝典】基础篇03数据读取与保存(Python版)
目录 保存为文本文件:saveAsTextFile 保存为json:saveAsTextFile 保存为SequenceFile:saveAsSequenceFile 读取hive 保存为文本文件:s ...
- legend3---2、网站的代码里面的/也是代表根目录
legend3---2.网站的代码里面的/也是代表根目录 一.总结 一句话总结: 不过这个根目录在public下面 1.mysql删除数据库命令? drop database <数据库名> ...