System.ObjectExtentions.ToJson C# (CSharp) Method

ToJson() public static method

Try to convert the current object into a json object
If the object cannot be converted then an exception will occur
public static ToJson ( this foo ) : string
foo this this
return string
        public static string ToJson(this object foo)
        {
            try
            {
                var s = new JavaScriptSerializer();
                return s.Serialize(foo);
            }
            catch (Exception e)
            {
                return e.Message;
            }
        }