mirror of
https://github.com/9ParsonsB/Pulsar.git
synced 2025-04-05 17:39:39 -04:00
19 lines
639 B
C#
19 lines
639 B
C#
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Observatory.Framework.Files.Converters;
|
|
|
|
class FleetCarrierTravelConverter : JsonConverter<float>
|
|
{
|
|
public override float Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
{
|
|
if (reader.TokenType == JsonTokenType.String)
|
|
return float.Parse(reader.GetString().Split(' ')[0]);
|
|
return reader.GetSingle();
|
|
}
|
|
|
|
public override void Write(Utf8JsonWriter writer, float value, JsonSerializerOptions options)
|
|
{
|
|
writer.WriteStringValue(value.ToString());
|
|
}
|
|
} |