c# 将json转换成Dictionary字符串

          方法一

               Dictionary<string, string> DicContent = postdata.Trim().Split(',').ToDictionary(s => s.Split(':')[0].Replace("\"", ""), s => s.Split(':')[1].Replace("\"", "")); 

      方法二

             JavaScriptSerializer s = new JavaScriptSerializer();


  string jsonTexts = "{\"count\":\"5550\",\"status\": \"200\",\"message\": \"success\",\"show_data\":[{\"productsId\":\"10025\",\"productName\":\"粉色波点裙蕾丝帽子熊 00190009\",\"discountPrice\":\"98.00\",\"defaultPrice\":\"null\",\"frontImg_160_160\":\"http://img.chaotianmen.com/upload/productimg/20140310/1403101454563877026_160_160.jpg\",\"frontImg\":\"http://img.chaotianmen.com/upload/productimg/20140310/1403101454563877026.jpg\",\"totalSales\":\"1\",\"shopName\":\"喜洋洋精品儿童玩具专卖店\"},{\"productsId\":\"10026\",\"productName\":\"粉色波点裙蕾丝帽子熊 00190009\",\"discountPrice\":\"98.00\",\"defaultPrice\":\"null\",\"frontImg_160_160\":\"http://img.chaotianmen.com/upload/productimg/20140310/1403101454563877026_160_160.jpg\",\"frontImg\":\"http://img.chaotianmen.com/upload/productimg/20140310/1403101454563877026.jpg\",\"totalSales\":\"1\",\"shopName\":\"喜洋洋精品儿童玩具专卖店\"}]}";

 

Dictionary<string, object> JsonData = (Dictionary<string, object>)s.DeserializeObject(jsonTexts);

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值