You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
983 B
28 lines
983 B
using System.Text.Json;
|
|
|
|
namespace Jellyfin.Extensions.Json;
|
|
|
|
/// <summary>
|
|
/// Extensions for Utf8JsonReader and Utf8JsonWriter.
|
|
/// </summary>
|
|
public static class Utf8JsonExtensions
|
|
{
|
|
/// <summary>
|
|
/// Determines if the reader contains an empty string.
|
|
/// </summary>
|
|
/// <param name="reader">The reader.</param>
|
|
/// <returns>Whether the reader contains an empty string.</returns>
|
|
public static bool IsEmptyString(this Utf8JsonReader reader)
|
|
=> reader.TokenType == JsonTokenType.String
|
|
&& ((reader.HasValueSequence && reader.ValueSequence.IsEmpty)
|
|
|| (!reader.HasValueSequence && reader.ValueSpan.IsEmpty));
|
|
|
|
/// <summary>
|
|
/// Determines if the reader contains a null value.
|
|
/// </summary>
|
|
/// <param name="reader">The reader.</param>
|
|
/// <returns>Whether the reader contains null.</returns>
|
|
public static bool IsNull(this Utf8JsonReader reader)
|
|
=> reader.TokenType == JsonTokenType.Null;
|
|
}
|