feat: Adds JSON convertibles (#1253)

This commit is contained in:
Kamron Batman 2022-11-15 18:19:05 -08:00 • committed by GitHub
parent ff79d3db40
commit 0abf72ed2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 108 additions and 1 deletions

View file

@ -95,9 +95,10 @@ public class Point2DConverter : JsonConverter<Point2D>
public override Point2D Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
reader.TokenType switch
{
JsonTokenType.String => Point2D.Parse(reader.GetString(), null),
JsonTokenType.StartArray => DeserializeArray(ref reader),
JsonTokenType.StartObject => DeserializeObj(ref reader),
_ => throw new JsonException("Invalid Json for Point3D")
_ => throw new JsonException("Invalid json for Point3D")
};
public override void Write(Utf8JsonWriter writer, Point2D value, JsonSerializerOptions options)