zoukankan      html  css  js  c++  java
  • 一、Json

     一、Json遍历模糊查询

     你没admin 所以这句话报错.

    //1、写法
    dynamic query = from user in jsonObject where (user.ToString().Contains("上海市")) select user;
    //2、写法
    var xx = jsonObject.Where(d => d["name"].ToString().Contains("上海市")).FirstOrDefault().Distinct();
    //没有集合 就是null 你对null进行去重 能不错吗
    

      

    二、dynamic:动态类型简单用法,写法

    class 动态创建数据
    {
        //动态类型:本质感觉跟object的用法差不多,只是在执行的时候才知道数据类型
        public dynamic Dynamic()
        {
            //定义一个动态类型,作为返回值
            dynamic data = new ExpandoObject();
            List<dynamic> list = new List<dynamic>();
            dynamic model = new ExpandoObject();
            model.ID = 1;
            model.Name = "张三";
            list.Add(model);
            data.list1 = list;
            return data;
        }
     
        public object Object()
        {
            //定义一个动态类型,作为返回值
            object data = new object();
            List<object> list = new List<object>();
            object model = new object();
            model.ID = 1;
            model.Name = "张三";
            list.Add(model);
            data.list1 = list;
            return data;
        }
    }
    

      

    三、DateTime

     

    static void Main(string[] args)
            {
    
                string str = "{"Token":"ew0KICAiVXNlckNvZGUiOiAiWmFubHVld29ya19Vc2VyIiwNCiAgIlVzZXJQYXNzV29yZCI6ICJBRjMzOUJFNzhCOUI0NEJDQjc1QThENThBREJBNkM4RSIsDQogICJJcEFkZHJlc3MiOiAiMTAxLjEzMi42Ny4yNDIiLA0KICAiRXhwaXJ5RGF0ZSI6ICIyMDE5LTA5LTI4VDIwOjA4OjI0LjU1MzIzODYrMDg6MDAiDQp9","Success":true,"StatusCode":0,"Message":"登录成功","OverTime":"2019-09-28 20:08:24"}";
                dynamic data = JsonConvert.DeserializeObject(str);
                var a = data.GetType().Name; 
    
                var b = data.OverTime;
                var bb = b.GetType();
    
                var c = data["OverTime"];
                var cc = c.GetType();
    
                DateTime dateTime = DateTime.Parse(c);//这个会报错 
    
                //获取分钟
                DateTime dateTime1 = DateTime.Parse(data["OverTime"]);//这个正常  你们谁在知道怎么回事
    
    
            }
  • 相关阅读:
    H5调用Android播放视频
    JavaScript调Java
    Java调用JavaScript
    python的下载和安装
    s5_day1作业
    s5_day2作业
    pycharm激活(转)
    for…else和while…else
    小练习
    09 grep、正则表达式和sed
  • 原文地址:https://www.cnblogs.com/fger/p/10917711.html
Copyright © 2011-2022 走看看