下面是memcached 中获取的obj 类型的数据,转list

            string sessionId = Request.Cookies["sessionId"].Value;//授权从Cookie中传递过来的Memcache的Key
Object obj = MemcachedHelper.Get(sessionId);//根据key从Memcache中获取用户的信息

// 序列化为JSON字串
string _json = JsonConvert.SerializeObject(obj);
List<UsersJsonParam> userInfo = new List<UsersJsonParam>(); // 反序列化
userInfo = JsonConvert.DeserializeObject<List<UsersJsonParam>>(obj.ToString());

不知为何

ICollection,IEnumerable 转换不行
            ICollection<object> list1 = obj as ICollection<object>;
IEnumerable<object> list2 = obj as IEnumerable<object>;

obj 转 IEnumerable

 /// <summary>
/// 这是子页面
/// </summary>
/// <returns></returns>
public ActionResult Edit()
{
//----查询 分组 数据列表 开始----
int Page = Convert.ToInt32(string.IsNullOrWhiteSpace(Request["page"]) ? "" : Request["page"]);
int limit = Convert.ToInt32(string.IsNullOrWhiteSpace(Request["limit"]) ? "" : Request["limit"]); Group Group = new Group(); Group.GroupId = Convert.ToInt32(string.IsNullOrWhiteSpace(Request["GroupId"]) ? "" : Request["GroupId"]);
Group.GroupCode = string.IsNullOrWhiteSpace(Request["GroupCode"]) ? "" : Request["GroupCode"];
Group.GroupName = string.IsNullOrWhiteSpace(Request["GroupName"]) ? "" : Request["GroupName"]; JsonResultDapper jrd = GroupManager.SelectGroupList(Group, Page, limit); //----查询 分组 数据列表 结束---- var selectItemList = new List<SelectListItem>() {
new SelectListItem(){ Value="", Text="--全部--", Selected=true }
}; IEnumerable<object> list = jrd.rows as IEnumerable<object>;
var GroupList = new SelectList(list, "GroupId", "GroupName"); selectItemList.AddRange(GroupList);
ViewBag.database = selectItemList; return PartialView();
}

Newtonsoft.Json 序列 反序列 IEnumerable的更多相关文章

  1. Json序列反序列类型处理帮助类

    Json序列反序列类型处理帮助类. JSON反序列化 JSON序列化 将Json序列化的时间由/Date(1294499956278+0800)转为字符串 将时间字符串转为Json时间 using S ...

  2. 分享基于.NET动态编译&Newtonsoft.Json封装实现JSON转换器(JsonConverter)原理及JSON操作技巧

    看文章标题就知道,本文的主题就是关于JSON,JSON转换器(JsonConverter)具有将C#定义的类源代码直接转换成对应的JSON字符串,以及将JSON字符串转换成对应的C#定义的类源代码,而 ...

  3. 调用newtonsoft.json反序列出错

    调用newtonsoft.json反序列出错: Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current J ...

  4. Newtonsoft.Json序列化和反序列之javascriptConvert.SerializeObject,DeserializeObject,JsonWriter,JsonReader

    这里下载:http://www.newtonsoft.com/products/json/安装:   1.解压下载文件,得到Newtonsoft.Json.dll   2.在项目中添加引用.. jav ...

  5. (转)Newtonsoft.Json序列化和反序列

    这里下载:http://www.newtonsoft.com/products/json/安装:   1.解压下载文件,得到Newtonsoft.Json.dll   2.在项目中添加引用.. 序列化 ...

  6. 将Dictionary序列化为json数据 、json数据反序列化为Dictionary

    需要引用System.Web.Extensions  dll类库 /// <summary> /// 将json数据反序列化为Dictionary /// </summary> ...

  7. 类对象序列化为json串,json串反序列化为类对象

    1.类对象序列化为json串: 方法一: class P(object): def __init__(self,name,age,sex): self.name=name self.age=age s ...

  8. C# Newtonsoft.Json反序列化为dynamic对象之后的使用

    通过Newtonsoft.Json将一个json类型的字符串反序列化为dynamic后直接使用报错 源代码: namespace ConsoleApplication1 { class Program ...

  9. Newtonsoft.Json序列化和反序列

    这里下载:http://www.newtonsoft.com/products/json/安装:   1.解压下载文件,得到Newtonsoft.Json.dll   2.在项目中添加引用.. 序列化 ...

随机推荐

  1. UI层复习笔记

    在main文件中,UIApplicationMain函数一共做了三件事 根据第三个参数创建了一个应用程序对象 默认写nil,即创建的是UIApplication类型的对象,此对象看成是整个应用程序的一 ...

  2. 【BZOJ3829】[Poi2014]FarmCraft 树形DP(贪心)

    [BZOJ3829][Poi2014]FarmCraft Description In a village called Byteville, there are   houses connected ...

  3. AEcs6破解版下载

    下载地址 http://pan.baidu.com/share/link?shareid=79184520&uk=1795677788 点击下载

  4. Less-mixin函数基础一

    //mixin函数 立即执行mixin函数,example: .test{ color:#ff00000; background:red; } //立即执行mixin grammar 1 扩展exte ...

  5. 《挑战程序设计竞赛》2.6 数学问题-素数 AOJ0009 POJ3126 3421 3292 3641

    AOJ0009 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009 题意 求不大于n的素数个数. 思路 素数筛法可解,筛法过程中 ...

  6. poco库 RSA加解密

    #include "poco/Crypto/Cipher.h"#include "poco/Crypto/CipherFactory.h"#include &q ...

  7. 【我的Android进阶之旅】解决SVN Cleanup错误: Failed to run the WC DB work queue associated with

    错误描述 在Android Studio中点击VCS向下箭头使用SVN Update功能更新代码的时候,报错如下所示: 错误描述信息: Error:svn: E155037: Previous ope ...

  8. 【我的Android进阶之旅】解决bug:You need to use a Theme.AppCompat theme (or descendant) with this activity.

    前言 今天用Android Studio 生成Activity的时候,默认继承AppCompatActivity ,而在AndroidManifest.xml我对该Activity设置了一个主题,然后 ...

  9. ionic3使用echart插件

    安装 看官方文档可以知道ECharts可以在webpack中使用看这里,故我们可以使用npm下载安装到项目中 npm install echarts --save //下载ECharts npm in ...

  10. tensorflow 中 name_scope 及 variable_scope 的异同

    Let's begin by a short introduction to variable sharing. It is a mechanism in TensorFlow that allows ...