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 = " ...
随机推荐
- 2018百度之星初赛B轮 p1m2
p1m2 Accepts: 954 Submissions: 4063 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/1310 ...
- 【BZOJ3811/UOJ36】 玛里苟斯
Description 魔法之龙玛里苟斯最近在为加基森拍卖师的削弱而感到伤心,于是他想了一道数学题. S 是一个可重集合,S={a1,a2,…,an}. 等概率随机取 S 的一个子集 A={ai1,… ...
- SQL简介及分类
SQL (Structured Query Language) 结构化查询语言,定义了所有操作关系型数据库的规则,只要是关系型数据库都需要用SQL语句: 语法: 一行可以有多个SQL语句,以分号结尾: ...
- [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 ...
- C语言的AES加密
C语言的AES加密 稍微封装了几个函数 方便使用 #if 1 #include <stdio.h> #include <stdlib.h> #include <strin ...
- ES6数组内对象去重
这个数组去重转自https://www.cnblogs.com/caideyipi/p/7679681.html, 就当笔记记录: 去重Set const arr = ['张三','张三','三张三' ...
- 【ASK】设置网卡启动遇到的事!
上次动笔是16年的事情了,一晃3年过去了.算了,不感慨了.直奔主题吧. 1.今天朋友要把一批win10的机器设置成网卡启动. 2.网卡是intel集成的. 3.按照主板说明已经设置成功. 4.通过wi ...
- ssh 多秘钥管理和坑
概述 很久之前就想研究一下 ssh 的多秘钥管理,今天正好有时间就研究了一下,挺简单的,记录下来,供以后开发时参考,相信对其他人也有用. 参考资料: Git - 生成 SSH公钥 , Linux 下多 ...
- C# AxWindowsMediaPlayer
AxWMPLib.AxWindowsMediaPlayer winPlayer = new AxWMPLib.AxWindowsMediaPlayer(); winPlayer.Dock = Dock ...
- 使用ffmpeg来转换media Video
FFMPEG -i 1.wmv -c:v libx264 -strict -2 1_wmv.mp4 ffmpeg -i b.mp4 -codec copy -bsf h264_mp4toannexb ...