Skip to content

Commit

Permalink
Fix Stringified converters
Browse files Browse the repository at this point in the history
  • Loading branch information
flobernd committed Nov 6, 2023
1 parent be7cf87 commit 36a54fc
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Serialization;
namespace Elastic.Clients.Elasticsearch.Serialization;
#endif

internal sealed class StringifiedLongConverter : JsonConverter<long?>
internal sealed class StringifiedLongConverter : JsonConverter<long>
{
public override long? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => ReadStringifiedLong(ref reader);
public override long Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => ReadStringifiedLong(ref reader);

public override void Write(Utf8JsonWriter writer, long? value, JsonSerializerOptions options) => writer.WriteNumberValue(value.Value);
public override void Write(Utf8JsonWriter writer, long value, JsonSerializerOptions options) => writer.WriteNumberValue(value);

public static long ReadStringifiedLong(ref Utf8JsonReader reader)
{
Expand All @@ -39,11 +39,11 @@ public static long ReadStringifiedLong(ref Utf8JsonReader reader)
}
}

internal sealed class StringifiedIntegerConverter : JsonConverter<int?>
internal sealed class StringifiedIntegerConverter : JsonConverter<int>
{
public override int? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => ReadStringifiedInteger(ref reader);
public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => ReadStringifiedInteger(ref reader);

public override void Write(Utf8JsonWriter writer, int? value, JsonSerializerOptions options) => writer.WriteNumberValue(value.Value);
public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options) => writer.WriteNumberValue(value);

public static int ReadStringifiedInteger(ref Utf8JsonReader reader)
{
Expand All @@ -66,11 +66,11 @@ public static int ReadStringifiedInteger(ref Utf8JsonReader reader)
}
}

internal sealed class StringifiedBoolConverter : JsonConverter<bool?>
internal sealed class StringifiedBoolConverter : JsonConverter<bool>
{
public override bool? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => ReadStringifiedBool(ref reader);
public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) => ReadStringifiedBool(ref reader);

public override void Write(Utf8JsonWriter writer, bool? value, JsonSerializerOptions options) => writer.WriteBooleanValue(value.Value);
public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options) => writer.WriteBooleanValue(value);

public static bool ReadStringifiedBool(ref Utf8JsonReader reader)
{
Expand Down

0 comments on commit 36a54fc

Please sign in to comment.