Example #1
0
 /// <summary>
 /// 从流中读取文本,解析出类型 <paramref name="type"/> 的对象。
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="reader"></param>
 /// <returns></returns>
 public T Deserialize <T>(JsonReader reader)
 {
     using (var deser = new JsonDeserialize(this, reader, Option))
     {
         return(deser.Deserialize <T>());
     }
 }
Example #2
0
        /// <summary>
        /// 从流中读取文本,解析出类型 <paramref name="type"/> 的对象。
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="reader"></param>
        /// <returns></returns>
        public T Deserialize <T>(JsonReader reader)
        {
            var deser = new JsonDeserialize(this, reader, Option);

            using (var context = new JsonConvertContext())
            {
                return(deser.Deserialize <T>());
            }
        }
Example #3
0
        public T Deserialize <T>(string json)
        {
            if (string.IsNullOrEmpty(json))
            {
                return(default(T));
            }

            using (var sr = new StringReader(json))
                using (var reader = new JsonReader(sr))
                    using (var deser = new JsonDeserialize(this, reader, Option))
                    {
                        return(deser.Deserialize <T>());
                    }
        }
Example #4
0
        public object Deserialize(string json, Type type)
        {
            if (string.IsNullOrEmpty(json))
            {
                return(null);
            }

            using (var sr = new StringReader(json))
                using (var reader = new JsonReader(sr))
                    using (var deser = new JsonDeserialize(this, reader, Option))
                    {
                        return(deser.Deserialize(type));
                    }
        }