27 lines
561 B
C#
27 lines
561 B
C#
using System.Text.Json;
|
|
|
|
namespace Oms.Application.Shared;
|
|
|
|
internal static class JsonStringArrayHelper
|
|
{
|
|
public static List<string> Deserialize(string? json)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(json))
|
|
{
|
|
return [];
|
|
}
|
|
|
|
return JsonSerializer.Deserialize<List<string>>(json) ?? [];
|
|
}
|
|
|
|
public static string? Serialize(IReadOnlyCollection<string>? items)
|
|
{
|
|
if (items == null || items.Count == 0)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return JsonSerializer.Serialize(items);
|
|
}
|
|
}
|