add jsonElement extension
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace SptCommon.Extensions
|
||||
{
|
||||
@@ -77,5 +78,11 @@ namespace SptCommon.Extensions
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static T ToObject<T>(this JsonElement element)
|
||||
{
|
||||
var json = element.GetRawText();
|
||||
return JsonSerializer.Deserialize<T>(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user