예제 #1
0
 public virtual HashJsonBU Concat(HashJsonBU json)
 {
     foreach (DictionaryEntry de in json)
     {
         this.Add(de.Key, de.Value);
     }
     return(this);
 }
예제 #2
0
        public HashJsonBU(string jsonStr) : base()
        {
            HashJsonBU json = HashJsonBU.Parse(jsonStr);

            foreach (DictionaryEntry de in json)
            {
                this.Add(de.Key, de.Value);
            }
        }
예제 #3
0
        /// <summary>
        /// 创建HashJson的副本
        /// </summary>
        /// <returns></returns>
        public virtual HashJsonBU CloneBase()
        {
            HashJsonBU hJson = new HashJsonBU();

            lock (this)
            {
                foreach (DictionaryEntry dic in this)
                {
                    hJson.Add(dic.Key, dic.Value);
                }
                return(hJson);
            }
        }
예제 #4
0
        public virtual HashJsonBU AryToHashJson(string [,] args)
        {
            HashJsonBU _json = new HashJsonBU();

            try{
                for (int i = 0; i < args.Length; i++)
                {
                    _json.Add(args[i, 0], args[i, 1]);
                }
            }catch (Exception e) {
                _json["ERROR"] = e.Message;
            }
            return(_json);
        }
예제 #5
0
        public static HashJsonBU Parse(string jsonStr)
        {
            HashJsonBU _json = new HashJsonBU();

            try
            {
                JObject obj = JObject.Parse(jsonStr);
                JEnumerable <JToken> _children = obj.Children();
                foreach (JProperty field in _children)
                {
                    string name  = field.Name;
                    string value = field.Value.ToString();
                    _json.Add(name, value);
                }
            }
            catch (Exception)
            {
            }
            return(_json);
        }