using System; using System.Text.Json; using System.Text.Json.Serialization; using Znyc.Recruitment.Admin.Commons.Extensions; namespace Znyc.Recruitment.Admin.Commons.Helpers { /// /// public class IntJsonConverter : JsonConverter { /// /// /// /// /// /// public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { if (reader.TokenType == JsonTokenType.Number) { return reader.GetInt32(); } return reader.GetString().ToInt(); } /// /// /// /// /// public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options) { writer.WriteNumberValue(value); } } }