diff options
| author | Bond-009 <bond.009@outlook.com> | 2020-08-26 18:59:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-26 18:59:46 +0200 |
| commit | 4f6c98b325aa544ac1f3a522ea668b3f990265e3 (patch) | |
| tree | 40c38d1a8d4214722b2fed816616cc0a22de7577 /MediaBrowser.Common/Json/Converters/JsonInt32Converter.cs | |
| parent | 4e3f26b647a9fe996b5a96ea10fa1f2468ea41fb (diff) | |
| parent | de4cfa223498dde4e665c452337f032c29270abe (diff) | |
Merge pull request #3984 from crobibero/json-prerelease
Use Prerelease System.Text.Json
Diffstat (limited to 'MediaBrowser.Common/Json/Converters/JsonInt32Converter.cs')
| -rw-r--r-- | MediaBrowser.Common/Json/Converters/JsonInt32Converter.cs | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/MediaBrowser.Common/Json/Converters/JsonInt32Converter.cs b/MediaBrowser.Common/Json/Converters/JsonInt32Converter.cs deleted file mode 100644 index 7ed9d6766..000000000 --- a/MediaBrowser.Common/Json/Converters/JsonInt32Converter.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Buffers; -using System.Buffers.Text; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace MediaBrowser.Common.Json.Converters -{ - /// <summary> - /// Converts a int32 object or value to/from JSON. - /// </summary> - public class JsonInt32Converter : JsonConverter<int> - { - /// <inheritdoc /> - public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType == JsonTokenType.String) - { - ReadOnlySpan<byte> span = reader.HasValueSequence ? reader.ValueSequence.ToArray() : reader.ValueSpan; - if (Utf8Parser.TryParse(span, out int number, out int bytesConsumed) && span.Length == bytesConsumed) - { - return number; - } - - if (int.TryParse(reader.GetString(), out number)) - { - return number; - } - } - - return reader.GetInt32(); - } - - /// <inheritdoc /> - public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options) - { - writer.WriteNumberValue(value); - } - } -} |
