using System.Text.Json; namespace Jellyfin.Extensions.Json; /// /// Extensions for Utf8JsonReader and Utf8JsonWriter. /// public static class Utf8JsonExtensions { /// /// Determines if the reader contains an empty string. /// /// The reader. /// Whether the reader contains an empty string. public static bool IsEmptyString(this Utf8JsonReader reader) => reader.TokenType == JsonTokenType.String && ((reader.HasValueSequence && reader.ValueSequence.IsEmpty) || (!reader.HasValueSequence && reader.ValueSpan.IsEmpty)); /// /// Determines if the reader contains a null value. /// /// The reader. /// Whether the reader contains null. public static bool IsNull(this Utf8JsonReader reader) => reader.TokenType == JsonTokenType.Null; }