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 = " ...
随机推荐
- 超实用的PHP代码片段!
摘要:本文分享了九个超级有用的PHP代码片段,当你在开发网站.应用或者博客时,利用这些代码能为你节省大量的时间.你可以直接拿来用! 此前,研发频道曾发布<直接拿来用,10个PHP代码片段> ...
- 【Python】学习笔记七:函数
函数的目的:重复使用相同的一段程序 函数的定义 下面是我自定义的一个求a,b,c三个参数平方和的函数 #a,b,c三个参数的平方和 def pow_sum(a,b,c): x = pow(a,2)+p ...
- hibernate多对一单项关联映射
1.实体类编写: 用户类: public class User { private int id; private String name; private Group group; ..... } ...
- ZXing使用详解与范例(C#)
介绍 ZXing是一个开放源码的,用Java实现的多种格式的1D/2D条码图像处理库,它包含了联系到其他语言的端口.Zxing可以实现使用手机的内置的摄像头完成条形码的扫描及解码.(引自百度百科) 用 ...
- Linux清空文本内容
测试文件:test.txt 第一种: $> test.txt 第二种: $echo "" > test.txt 第三种: $cat /dev/null > tes ...
- 杂项-PIN:百科
ylbtech-杂项-PIN:百科 个人身份识别码(英语:Personal identification number,缩写为 PIN),又译为用户个人识别号码,常被称为PIN码(PIN number ...
- VSCode - 使用 WSL(Windows Subsystem for Linux)
一开始我是只将 VSCode 集成的终端改成 WSL 的 Bash,结果发现内置的 GIt 用的还是 Windows 的 Git,Git Hooks 用的 Windows 的环境,上网搜了一下发现有很 ...
- window.screenLeft&&window.screenTop&&window.screenX&&window.screenY
http://blog.sina.com.cn/s/blog_14e2a237b0102w4i0.html window.screenLeft&&window.screenTop&am ...
- OPEN SQL:插入、删除、修改语法
1. UPDATE 用于实现对数据据的更新操作,语法如下: UPDATE <dbtab> set f1...fn (where <condition>). UPDATE < ...
- jenkins中通过Publish Over SSH将项目部署到远程机器上
Publish Over SSH插件使用在使用Publish Over SSH之前,需要制作SSH私钥.机器间做免密登录配置.假设机器A,ip为192.168.AA.AAA,机器B: 192.168. ...