• Json随笔


    1、Json反序列化为对象,再通过where条件查询集合中的某条信息   反序列化需引用LitJson.dll

      List<City> List_City = JsonMapper.ToObject<List<City>>(city_json_info);
      var list = List_City.Where(m => m.name == SignCity);
      IList<City> IList_City = list.ToArray();
      string City_Spell = "";
      foreach (var item in IList_City)
      {
          City_Spell = item.pinyin;
      }

    2、得到集合中的某些列

      IList<OperaterInfo> resultOpers = client.GetSubEmpsForPage(parms, values, pageNum, pageSize);
      int count = client.GetSubEmpsRowCount(parms, values);
      var list = resultOpers.Select(m => new
      {
      m.DepName,
      m.LoginName,
      m.OptId,
      RoleName = string.Join(",", m.Roles.Select(r => r.RoleName)),
      m.Name
      });

    3、将对象转为Json  需引用Nettonsoft.Json.dll

       string strJson = JsonConvert.SerializeObject(Class_BIGBODY);   

       //Json转XML

       XmlDocument xmlDoc = JsonConvert.DeserializeXmlNode(strJson);

  • 相关阅读:
    JNI 反射
    JNI 动态注册
    Nt* 与 Zw* 区别
    python之线程
    爬虫框架之Scrapy(四 ImagePipeline)
    初试PySnooper
    爬虫框架之Scrapy(三 CrawlSpider)
    爬虫框架之Scrapy(二)
    爬虫框架之Scrapy(一)
    selenium+谷歌无头浏览器爬取网易新闻国内板块
  • 原文地址:https://www.cnblogs.com/weijiafd/p/4627666.html
Copyright © 2020-2023  润新知