Last active
February 25, 2022 09:18
-
-
Save AndyHuang1223/58a14ab4677e408f652a62b348e31ec7 to your computer and use it in GitHub Desktop.
This file contains 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 characters
public static class JsonParseExtension | |
{ | |
public static bool JsonTryParse<T>(this string jsonString, out T result) where T : class | |
{ | |
try | |
{ | |
result = JsonSerializer.Deserialize<T>(jsonString); | |
return true; | |
} | |
catch(Exception e) | |
{ | |
result = default; | |
Debug.WriteLine(e.Message); | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment