public static string JsonStringFormat(string str)
{
if (str.IsNullOrEmpty())
{
return str;
}
try
{
var obj = System.Text.Json.JsonSerializer.Deserialize<object>(str);
return System.Text.Json.JsonSerializer.Serialize(obj, typeof(object), new System.Text.Json.JsonSerializerOptions
{
WriteIndented = true,
});
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
return str;
}