System.ObjectExtentions.ToJson C# (CSharp) Метод

ToJson() публичный статический Метод

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
Результат string
        public static string ToJson(this object foo)
        {
            try
            {
                var s = new JavaScriptSerializer();
                return s.Serialize(foo);
            }
            catch (Exception e)
            {
                return e.Message;
            }
        }