C# json直接转成Dictionary

 

 

string st = "{\"1\":0,\"2\":1,\"3\":9,\"4\":0,\"5\":0,\"6\":0,\"7\":0,\"8\":0,\"9\":0,\"10\":0,\"11\":0,\"12\":0,\"13\":0,\"14\":0,\"15\":0,\"16\":0,\"17\":0,\"18\":0,\"19\":0,\"20\":0,\"21\":0}";
Dictionary<string, object> dd = st.Trim(new char[] { '{', '}' }).Split(',').ToDictionary(s => s.Split(':')[0], s => (object)s.Split(':')[1]);

 

posted @ 2017-04-28 14:50  51nb  阅读(4491)  评论(1编辑  收藏  举报