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. mvc正则@符号js报错解决办法

    很简单在@前面再加个@就行了,也可以以引进js 的形式解决!

  2. javaweb实验五

    product类: package com.lab;public class Product { private int id;                // 商品编号    private S ...

  3. Spring.Net 配置文件

    方法一. 直接在程序配置文件中配置 <configuration> <configSections> <sectionGroup name="spring&qu ...

  4. Android中layout_gravity和gravity的区别

    安卓中的 layout_gravity 属性和 gravity属性 有啥区别? LinearLayout有两个非常相似的属性: android:gravity与android:layout_gravi ...

  5. MySQL进阶

    小知识: \G 放到sql语句后,可以使每个字段打印到单独的行,如: mysql> select * from user_msg limit 2 \G; 一.增加删除表字段的ALTER命令: A ...

  6. BZOJ1857[SCOI2010]传送带

    题目大意:平面上两条线段,一个人从一条线段的一个点到另一条线段的一个点,最小时间是多少 路径肯定是在一条线段上走一段,然后走平面,最后再走另一条线段,那么需要确定的就是在两条线段上走的距离,其他暴力算 ...

  7. poj2305-Basic remains(进制转换 + 大整数取模)

    进制转换 + 大整数取模一,题意: 在b进制下,求p%m,再装换成b进制输出. 其中p为b进制大数1000位以内,m为b进制数9位以内二,思路: 1,以字符串的形式输入p,m; 2,转换:字符串-&g ...

  8. 微信H5页面分享

    #jssdk.php <?php class JSSDK { private $appId; private $appSecret; public function __construct($a ...

  9. 回归测试---junit

    回归测试是指修改了旧代码后,重新进行测试以确认修改没有引入新的错误或导致其他代码产生错误. JUnit是一个Java语言的单元测试框架. http://blog.csdn.net/andycpp/ar ...

  10. [Ubuntu][Linux]更改PATH路径

    1.什么是环境变量(PATH) 在Linux中,在执行命令时,系统会按照PATH的设置,去每个PATH定义的路径下搜索执行文件,先搜索到的文件先执行. 我们知道查阅文件属性的指令ls 完整文件名为:/ ...