Вроде все ошибки устранил. не запускал.

This commit is contained in:
Mikhail Trubnikov
2023-06-13 15:04:47 +10:00
parent b22c401156
commit ab7e88c0ff
14 changed files with 175 additions and 28 deletions

View File

@@ -0,0 +1,30 @@
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Unicode;
namespace PARR.DAL.Extensions
{
public static class GeneralExtesions
{
/// <summary>
/// Преобразует объект в Json, с учетом Cyrillic
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string? ToJson(this object value)
{
if (value == null)
return null;
try
{
return JsonSerializer.Serialize(value, new JsonSerializerOptions { Encoder = JavaScriptEncoder.Create(UnicodeRanges.All, UnicodeRanges.Cyrillic) }); ;
}
catch// (Exception ex)
{
// todo: писать лог??? или и так пойдет
return null;
}
}
}
}