Files
PCK-Studio/PckStudio.Core/Extensions/JObjectExtensions.cs
2025-12-12 05:12:17 +01:00

24 lines
606 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace PckStudio.Core.Extensions
{
internal static class JObjectExtensions
{
public static bool TryGetValue<T>(this JObject jObject, string propertyName, out T value)
{
if (!jObject.TryGetValue(propertyName, out JToken token))
{
value = default;
return false;
}
value = token.ToObject<T>() ?? default;
return value is T;
}
}
}