public virtual void parse(String json)
        {
            if (!result.ok())
            {
                this.exception = new BmobException(result.ToString());
                this.data      = default(T);
            }
            else
            {
                var type = typeof(T);
                if (type.IsArray || typeof(IList).IsAssignableFrom(type))
                {
                    // batch or ...
                    var raw = (IList)JsonAdapter.JSON.ToObject(json);
                    this.data = BmobInput.Parse <T>(raw);
                }
                else
                {
                    // 解析[CRUD]的返回值对象
                    var raw = (IDictionary <String, Object>)JsonAdapter.JSON.ToObject(json);

                    this.data = BmobInput.Parse <T>(raw);
                }
            }
        }
Exemple #2
0
        public virtual void parse(String json)
        {
            if (!result.ok())
            {
                // RestAPI 如果不是200,说明返回内容有“错误”,此时解析内容
                var raw    = (IDictionary <String, Object>)JsonAdapter.JSON.ToObject(json);
                var status = BmobInput.Parse <Status>(raw);

                this.exception = new BmobException(status.code == null ? result : status);
                this.data      = default(T);
            }
            else
            {
                var type = typeof(T);
                if (type.IsArray || typeof(IList).IsAssignableFrom(type))
                {
                    // batch or ...
                    var raw = (IList)JsonAdapter.JSON.ToObject(json);
                    this.data = BmobInput.Parse <T>(raw);
                }
                else
                {
                    // 解析[CRUD]的返回值对象
                    var raw = (IDictionary <String, Object>)JsonAdapter.JSON.ToObject(json);
                    this.data = BmobInput.Parse <T>(raw);
                }
            }
        }