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.
26 lines
795 B
26 lines
795 B
4 years ago
|
using System;
|
||
|
using System.Text.Json;
|
||
|
using System.Text.Json.Serialization;
|
||
|
|
||
3 years ago
|
namespace Jellyfin.Extensions.Json.Converters
|
||
4 years ago
|
{
|
||
|
/// <summary>
|
||
|
/// Converts an object to a lowercase string.
|
||
|
/// </summary>
|
||
|
/// <typeparam name="T">The object type.</typeparam>
|
||
|
public class JsonLowerCaseConverter<T> : JsonConverter<T>
|
||
|
{
|
||
|
/// <inheritdoc />
|
||
3 years ago
|
public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||
4 years ago
|
{
|
||
|
return JsonSerializer.Deserialize<T>(ref reader, options);
|
||
|
}
|
||
|
|
||
|
/// <inheritdoc />
|
||
|
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
|
||
|
{
|
||
3 years ago
|
writer.WriteStringValue(value?.ToString()?.ToLowerInvariant());
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|