Last active
September 16, 2018 17:18
Revisions
-
brainded revised this gist
Dec 1, 2014 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,11 @@ public static class ObjectExtensions /// The string representation of null. /// </summary> private static readonly string Null = "null"; /// <summary> /// The string representation of exception. /// </summary> private static readonly string Exception = "Exception"; /// <summary> /// To json. @@ -12,10 +17,7 @@ public static class ObjectExtensions /// <returns>The Json of any object.</returns> public static string ToJson(this object value) { if (value == null) return Null; try { @@ -25,7 +27,7 @@ public static string ToJson(this object value) catch (Exception exception) { //log exception but dont throw one return Exception; } } } -
brainded renamed this gist
Jan 31, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
brainded created this gist
Jan 29, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ public static class ObjectExtensions { /// <summary> /// The string representation of null. /// </summary> private static readonly string Null = "null"; /// <summary> /// To json. /// </summary> /// <param name="value">The value.</param> /// <returns>The Json of any object.</returns> public static string ToJson(this object value) { if (value == null) { return Null; } try { string json = JsonConvert.SerializeObject(value); return json; } catch (Exception exception) { //log exception but dont throw one return string.Empty; } } }