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例子的更多相关文章

  1. ASP.net解析JSON

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  2. Asp.net 解析json

    Asp.net Json数据解析的一种思路 http://www.cnblogs.com/scy251147/p/3317366.html http://tools.wx6.org/json2csha ...

  3. Asp.Net解析json字符串

    方法一: using LitJson; string json= "{...........}"; JsonData jdData = JsonMapper.ToObject(js ...

  4. ASP( VBScript ) 解析 JSON

    <script language="jscript" runat="server"> Array.prototype.get = function( ...

  5. Gson解析json数据(转)

    一. www.json.org这是JSON的官方网站. 首先,我,我们需要在code.google.com/p/google-gson/downloads/list下载JSON的jar包,解析后把gs ...

  6. JackSon解析json字符串

    JackSon解析json字符串 原文:http://blog.csdn.net/java_huashan/article/details/9353903 概述 jackson解析json例子 准备工 ...

  7. ASP.NET与json对象互转

    这两天写这个xml跟json的读写,心累啊,也不是很理解,请大家多指教 首先来个热身菜做一个简单的解析json 在script里写一个简单的弹窗效果 <script> //script里简 ...

  8. ASP.NET 使用 System.Web.Script.Serialization 解析 JSON (转)

    JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.易于人阅读和编写.同时也易于机器解析和生成.它基于JavaScript Programming Langu ...

  9. asp.net中json格式化及在js中解析json

    类: public class UploadDocumentItem { public UploadDocumentItem() { } public string DocMuid { get; se ...

随机推荐

  1. CSS3 Animation

    animation:[<animation-name> || <animation-duration> || <animation-timing-function> ...

  2. win10我能ping通他人,但他人ping不同我

    这是防火墙的原因,关闭防火墙即可

  3. jquery 取消绑定事件

    $(".TreeView1_0").unbind("mouseover"); $("#id").attr("onclick&quo ...

  4. 【iCore3 双核心板_FPGA】实验十七:基于I2C总线的ARM与FPGA通信实验

    实验指导书及代码包下载: http://pan.baidu.com/s/1dFqddMp iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...

  5. 带清空按钮的EditText

    public class ClearEditText extends EditText implements OnFocusChangeListener, TextWatcher { // 删除按钮的 ...

  6. C#整数三种强制类型转换int、Convert.ToInt32()、int.Parse()的区别

    1.int适合简单数据类型之间的转换,C#的默认整型是int32(不支持bool型); 2.int.Parse(string sParameter)是个构造函数,参数类型只支持string类型; 3. ...

  7. 【java基础学习】字符串

    字符串 1. java内存区域(堆区.栈区.常量池) 2. String方法 获取长度 length(); 获取位置 indexOf(index); lastIndexOf(index) 获取子串 c ...

  8. 《Linux内核设计与实现》CHAPTER4阅读梳理

    <Linux内核设计与实现>CHAPTER4阅读梳理 [学习时间:3hours] [学习内容:多任务:进程调度策略:Linux中进程调度的关键问题:抢占] 个人思考部分见[]标出的部分 一 ...

  9. [转]Android SHA1与Package获取方式

    转自高德地图LBS Android SHA1与Package获取方式 获取应用包名 打开Android 应用工程的 AndroidManifest.xml配置文件,package 属性所对应的内容为应 ...

  10. 安卓和ios的lineheight的不一样如何解决?

    lineheight在pc端上显示很正常,但是在手机就很不同,在iphone6上,设置了lineheight,但是文本上面多了几像素,如果你设置lineheight在35px一下的按钮(用span做的 ...