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. 2018百度之星初赛B轮 p1m2

    p1m2 Accepts: 954 Submissions: 4063 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/1310 ...

  2. 【BZOJ3811/UOJ36】 玛里苟斯

    Description 魔法之龙玛里苟斯最近在为加基森拍卖师的削弱而感到伤心,于是他想了一道数学题. S 是一个可重集合,S={a1,a2,…,an}. 等概率随机取 S 的一个子集 A={ai1,… ...

  3. SQL简介及分类

    SQL (Structured Query Language) 结构化查询语言,定义了所有操作关系型数据库的规则,只要是关系型数据库都需要用SQL语句: 语法: 一行可以有多个SQL语句,以分号结尾: ...

  4. [LeetCode]-DataBase-Trips and Users

    The Trips table holds all taxi trips. Each trip has a unique Id, while Client_Id and Driver_Id are b ...

  5. C语言的AES加密

    C语言的AES加密 稍微封装了几个函数 方便使用 #if 1 #include <stdio.h> #include <stdlib.h> #include <strin ...

  6. ES6数组内对象去重

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

  7. 【ASK】设置网卡启动遇到的事!

    上次动笔是16年的事情了,一晃3年过去了.算了,不感慨了.直奔主题吧. 1.今天朋友要把一批win10的机器设置成网卡启动. 2.网卡是intel集成的. 3.按照主板说明已经设置成功. 4.通过wi ...

  8. ssh 多秘钥管理和坑

    概述 很久之前就想研究一下 ssh 的多秘钥管理,今天正好有时间就研究了一下,挺简单的,记录下来,供以后开发时参考,相信对其他人也有用. 参考资料: Git - 生成 SSH公钥 , Linux 下多 ...

  9. C# AxWindowsMediaPlayer

    AxWMPLib.AxWindowsMediaPlayer winPlayer = new AxWMPLib.AxWindowsMediaPlayer(); winPlayer.Dock = Dock ...

  10. 使用ffmpeg来转换media Video

    FFMPEG -i 1.wmv -c:v libx264 -strict -2 1_wmv.mp4 ffmpeg -i b.mp4 -codec copy -bsf h264_mp4toannexb ...