Ejemplo n.º 1
0
 /// <summary>
 /// 模型是对象,key对应是集合,返回集合
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public CommonJsonModel GetCollection(string key)
 {
     if (!isModel)
     {
         return(null);
     }
     if (string.IsNullOrEmpty(key))
     {
         return(null);
     }
     foreach (string subjson in base._GetCollection(this.rawjson))
     {
         CommonJsonModel model = new CommonJsonModel(subjson);
         if (!model.IsValue())
         {
             continue;
         }
         if (model.Key == key)
         {
             CommonJsonModel submodel = new CommonJsonModel(model.Value);
             if (!submodel.IsCollection())
             {
                 return(null);
             }
             else
             {
                 return(submodel);
             }
         }
     }
     return(null);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 当模型是对象,返回拥有的key
        /// </summary>
        /// <returns></returns>
        public List <string> GetKeys()
        {
            if (!isModel)
            {
                return(null);
            }
            List <string> list = new List <string>();

            foreach (string subjson in base._GetCollection(this.rawjson))
            {
                string key = new CommonJsonModel(subjson).Key;
                if (!string.IsNullOrEmpty(key))
                {
                    list.Add(key);
                }
            }
            return(list);
        }