aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Json/Converters/JsonStringConverter.cs
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2021-06-19 18:02:33 +0200
committerBond_009 <bond.009@outlook.com>2021-06-19 18:04:46 +0200
commit6f8ccab788e85e025eaa44b67a1487bf419afb53 (patch)
treef8895fae8ec17e922daab473180c9de9a702a02a /MediaBrowser.Common/Json/Converters/JsonStringConverter.cs
parent0c3dcdf77b0d124517bffa608bfddf7d8f7682db (diff)
Move non-jellyfin extensions to separate project
Diffstat (limited to 'MediaBrowser.Common/Json/Converters/JsonStringConverter.cs')
-rw-r--r--MediaBrowser.Common/Json/Converters/JsonStringConverter.cs39
1 files changed, 0 insertions, 39 deletions
diff --git a/MediaBrowser.Common/Json/Converters/JsonStringConverter.cs b/MediaBrowser.Common/Json/Converters/JsonStringConverter.cs
deleted file mode 100644
index 6cd980e48..000000000
--- a/MediaBrowser.Common/Json/Converters/JsonStringConverter.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Buffers;
-using System.Text;
-using System.Text.Json;
-using System.Text.Json.Serialization;
-
-namespace MediaBrowser.Common.Json.Converters
-{
- /// <summary>
- /// Converter to allow the serializer to read strings.
- /// </summary>
- public class JsonStringConverter : JsonConverter<string?>
- {
- /// <inheritdoc />
- public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
- {
- return reader.TokenType switch
- {
- JsonTokenType.Null => null,
- JsonTokenType.String => reader.GetString(),
- _ => GetRawValue(reader)
- };
- }
-
- /// <inheritdoc />
- public override void Write(Utf8JsonWriter writer, string? value, JsonSerializerOptions options)
- {
- writer.WriteStringValue(value);
- }
-
- private static string GetRawValue(Utf8JsonReader reader)
- {
- var utf8Bytes = reader.HasValueSequence
- ? reader.ValueSequence.ToArray()
- : reader.ValueSpan;
- return Encoding.UTF8.GetString(utf8Bytes);
- }
- }
-}