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. jquery中对动态生成的标签响应click事件(二)…与ajax交互使用

    <%@ page language="java" contentType="text/html; charset=GB18030" pageEncodin ...

  2. C++重载operator的示例

    #include<iostream>#include<vector>using namespace std; class test{public:     int v;   / ...

  3. jquery ui bootstrap日期插件

    http://blog.csdn.net/php_897721669/article/details/7404527 搜索“jquery ui日期插件怎么显示年份”? $("#datepic ...

  4. Varnish安装使用(初学)

    本人对varnish也是新手,这里记录一下安装步骤! 环境:centos6.6 varnish安装包下载:wget https://repo.varnish-cache.org/source/varn ...

  5. DBConfigReader.java

    package com.vcredit.ddcash.batch.util; import java.sql.Connection;import java.sql.PreparedStatement; ...

  6. Bootstrap css背景图片的设置

    一. 网页中添加图片的方式有两种 一种是:通过<img>标签直接插入到html中 另一种是:通过css背景属性添加 居中方法:水平居中的text-align:center 和 margin ...

  7. BizTalk开发系列(十九) BizTalk命名规范

    目前BizTalk项目的开发人员比较少,但是在开发过程中还是需要命名规范的约束.根据以往BizTalk项目的经验,整理了BizTalk命 名规范.包括:BizTalk Application, Sch ...

  8. html本地服务器

    html本地服务器 http://files.cnblogs.com/files/douxuyao/Aws.rar

  9. PowerDesigner 15.2入门学习 一

    好久没有搞 PowerDesigner 然后记录一下 1.下载地址 http://download.sybase.com/eval/PowerDesigner/PowerDesigner152_Eva ...

  10. Flex HTTPService json

    import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; import mx.rpc.http.HTTPService; i ...