Surendra Sharma

Surendra Sharma

Search This Blog

Wednesday, June 5, 2013

DeSerailizes Json string to specific object

DeSerailizes Json string to specific object

/// <summary>
        /// DeSerailizes Json string to specific object
        /// </summary>
        /// <typeparam name="T">Type of Object</typeparam>
        /// <param name="jsonObject">Json String to be converted to Collection</param>
        /// <param name="recursionDepth">Recursion depth optional paramter</param>
        /// <returns>Collection of Object from Json Response</returns>
        public static T ToObject<T>(this string jsonObject, int recursionDepth = 100) {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            serializer.RecursionLimit = recursionDepth;
            return serializer.Deserialize<T>(jsonObject);

        }

No comments:

Post a Comment