ASP.net解析JSON
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的更多相关文章
- ASP.net解析JSON例子
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- Asp.net 解析json
Asp.net Json数据解析的一种思路 http://www.cnblogs.com/scy251147/p/3317366.html http://tools.wx6.org/json2csha ...
- Asp.Net解析json字符串
方法一: using LitJson; string json= "{...........}"; JsonData jdData = JsonMapper.ToObject(js ...
- ASP( VBScript ) 解析 JSON
<script language="jscript" runat="server"> Array.prototype.get = function( ...
- ASP.NET与json对象互转
这两天写这个xml跟json的读写,心累啊,也不是很理解,请大家多指教 首先来个热身菜做一个简单的解析json 在script里写一个简单的弹窗效果 <script> //script里简 ...
- ASP.NET 使用 System.Web.Script.Serialization 解析 JSON (转)
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.易于人阅读和编写.同时也易于机器解析和生成.它基于JavaScript Programming Langu ...
- asp.net中json格式化及在js中解析json
类: public class UploadDocumentItem { public UploadDocumentItem() { } public string DocMuid { get; se ...
- 《项目经验》--通过js获取前台数据向一般处理程序传递Json数据,并解析Json数据,将前台传来的Json数据写入数据库表中
先看一下我要实现的功能界面: 这个界面的功能在图中已有展现,课程分配(教师教授哪门课程)在之前的页面中已做好.这个页面主要实现的是授课,即给老师教授的课程分配学生.此页面实现功能的步骤已在页面 ...
- 使用 dynamic 标记解析JSON字符串 JDynamic :支持Json反序列化为Dynamic对象
使用 dynamic 标记解析JSON字符串 http://www.cnblogs.com/taotaodetuer/p/4171327.html 1 string jsonStr = " ...
随机推荐
- SQL基础-order by
若sql语句中order by指定了多个字段,则怎么排序? 举个例子吧:order by id desc,time desc 先是按 id 降序排列 (优先)如果 id 字段 有些是一样的话 再 ...
- vue 路由懒加载 resolve vue-router配置
使用方法 component:resolve => require(['@/pages/About'],resolve) //"@"相当于".." 懒加载 ...
- CentOS 7 安装wps2019
1. download https://www.wps.cn/product/wpslinux 2. rpm 安装缺少lib包,于是yum 安装 .x86_64.rpm 3.安装完成,运行的时候又报错 ...
- CSS注
1.css3内容上下左右居中 .box { display:-moz-box; -moz-box-pack:center; -moz-box-align:center; display:-webkit ...
- 异步实时搜索jquery select插件
异步实时搜索jquery select插件 一.先看看效果. 二.做此插件的原因. 1.数据量过大(几千.几万条),无法一次性全部加载. 2.现有插件各不相同,无法满足功能需求. 3.美观性,可控性不 ...
- Ubuntu 12.04输入密码登陆后又跳回到登录界面
先找到这个文件: /home/user/.xsession-errors 打开这个文件. 这个文件记录了系统启动的日志,从这里你就可以看到启动的时候哪里出了问题. 对于我的来说,问题出在这里: & ...
- sklearn—无监督最近邻
无监督最近邻 NearestNeighbors (最近邻)实现了 unsupervised nearest neighbors learning(无监督的最近邻学习). 它为三种不同的最近邻算法提供统 ...
- EDM数据:如何选择邮件服务器平台
博主知道有不少的企业和个人都在寻找邮件服务器平台,下面博主从下面几个方面给大家介绍一下如何选择. 一.列表管理功能是否完善. 一般一个好的邮件服务器平台系统都有完善的列表管理功能.列表管理功能是指邮件 ...
- HAProxy & Keepalived L4-L7 高可用负载均衡解决方案
目录 文章目录 目录 HAProxy 负载均衡器 应用特性 性能优势 会话保持 健康检查 配置文件 负载均衡策略 ACL 规则 Web 监控平台 Keepalived 虚拟路由器 核心组件 VRRP ...
- Dataframe的索引问题
1 两个Dataframe相加时,一定要注意索引是否对应再相加,利用这个特点有时可以先用set_index()将某些列置为索引列,再进行相加. import pandas as pd df1 = pd ...