Files
SPT-Server-Build/Libraries/SPTarkov.Server.Core/Utils/Json/Converters/ToStringJsonConverter.cs
T
DrakiaXYZ b416d7109a Fix launcher not showing mods
Convert `Version` and `SptVersion` to strings when serializing JSON for AbstractModMetadata
2025-10-11 22:44:27 -07:00

25 lines
691 B
C#

using System.Text.Json;
using System.Text.Json.Serialization;
namespace SPTarkov.Server.Core.Utils.Json.Converters;
internal class ToStringJsonConverter<T> : JsonConverter<T>
{
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
throw new NotSupportedException($"Deserialization of {typeof(T).Name} from string is not supported.");
}
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
{
if (value == null)
{
writer.WriteNullValue();
}
else
{
writer.WriteStringValue(value.ToString());
}
}
}