You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
689 B

  1. using IPA.Utilities;
  2. using System;
  3. using System.Text.Json;
  4. using System.Text.Json.Serialization;
  5. namespace IPA.JsonConverters
  6. {
  7. internal class AlmostVersionConverter : JsonConverter<AlmostVersion>
  8. {
  9. public override AlmostVersion Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
  10. reader.TokenType == JsonTokenType.Null ? null : new AlmostVersion(reader.GetString());
  11. public override void Write(Utf8JsonWriter writer, AlmostVersion value, JsonSerializerOptions options)
  12. {
  13. if (value == null) writer.WriteNullValue();
  14. else writer.WriteStringValue(value.ToString());
  15. }
  16. }
  17. }