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<stringobject> json = (Dictionary<stringobject>)serializer.DeserializeObject(JSON);
        object[] info = (object[])json["info"];
        Dictionary<stringobject> val;
        Dictionary<intstring> Objs = null;
        Dictionary<intstring> fileOldName = null;
        for (int i = 0; i < info.Length; i++)
        {
 
            val = (Dictionary<stringobject>)info[i];
 
            foreach (KeyValuePair<stringobject> str in val)
            {
                //保存信息到 session
                if (Session["bigfile_info"] == null)
                {
                    Objs = new Dictionary<intstring>();
                    Session["bigfile_info"] = Objs;
                }
                 
                if (Session["file_name"] == null)
                {
                    fileOldName = new Dictionary<intstring>();
                    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<intstring>)Session["file_name"];
            foreach (int 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. ASP.NET与json对象互转

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

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

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

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

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

  8. 《项目经验》--通过js获取前台数据向一般处理程序传递Json数据,并解析Json数据,将前台传来的Json数据写入数据库表中

      先看一下我要实现的功能界面:   这个界面的功能在图中已有展现,课程分配(教师教授哪门课程)在之前的页面中已做好.这个页面主要实现的是授课,即给老师教授的课程分配学生.此页面实现功能的步骤已在页面 ...

  9. 使用 dynamic 标记解析JSON字符串 JDynamic :支持Json反序列化为Dynamic对象

    使用 dynamic 标记解析JSON字符串  http://www.cnblogs.com/taotaodetuer/p/4171327.html 1 string jsonStr = " ...

随机推荐

  1. UNIX标准C - 进程之间的通信

    一.基本概念 进程间通信IPC:进程之间交换数据的过程叫进程间通信 进程间同性的方式: 简单的进程间的通信: 命令行:父进程通过exec函数创建子进程是可以附加一些数据 环境变量表:父进程通过exec ...

  2. 为什么C++中只有指针和引用才能实现多态?

    代码: class A { public: virtual void Debug(){} }; class B:public A { public: virtual void Debug(){} }; ...

  3. 南京网络赛 E K Sum

    K Sum 终于过了这玩意啊啊啊==== 莫比乌斯反演,杜教筛,各种分块,积性函数怎么线性递推还很迷==,得继续研究研究 #include<bits/stdc++.h> using nam ...

  4. 《数据结构(C语言)》苏小红 课本案例

    期末了,赶紧复习一波,手打一份书上的代码以便随时查阅 第二章: //顺序表存储结构 #define MAXSIZE 100 typedef struct { Elemtype *elemt; int ...

  5. maven 配置私服 连接

    两种方法: 1.在单个项目的pom.xml中使用 私服的连接地址,这样只对该项目起作用. 2.在maven的setting.xml配置中添加私服的连接地址.这样对所有项目起作用. 本文章只演示第二种方 ...

  6. 关于viewpager的滑动问题

    今天碰到很诡异的问题,viewpager中放置至少三张图片的时候能够正常实现循环滑动,只放置一张或者两张的时候就不行. 后来发现问题症结:viewpager需要保证既可以向左滑动,又可以向右滑动,因此 ...

  7. 后盾网lavarel视频项目---laravel 使用laracasts/flash插件提示信息

    后盾网lavarel视频项目---laravel 使用laracasts/flash插件提示信息 一.总结 一句话总结: laracasts/flash插件的效果就是一个弹出的boostrap模块框, ...

  8. 后盾网lavarel视频项目---页面post方式提交之后动态弹出错误信息

    后盾网lavarel视频项目---页面post方式提交之后动态弹出错误信息 一.总结 一句话总结: 1.思路和我想的一样,有错误的时候弹出提示错误消息的模态框就好,没有错误的时候不管它 2.把模态框的 ...

  9. ES6数组内对象去重

    这个数组去重转自https://www.cnblogs.com/caideyipi/p/7679681.html, 就当笔记记录: 去重Set const arr = ['张三','张三','三张三' ...

  10. leetcode-mid-sorting and searching-34 Search for a Range

    mycode   63.98% class Solution(object): def searchRange(self, nums, target): """ :typ ...