您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
32 行
968 B
32 行
968 B
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
using Newtonsoft.Json.Utilities;
|
|
using UnityEngine;
|
|
|
|
namespace Unity.Services.Lobbies.Http
|
|
{
|
|
internal static class JsonHelpers
|
|
{
|
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]
|
|
internal static void RegisterTypesForAOT()
|
|
{
|
|
AotHelper.EnsureType<StringEnumConverter>();
|
|
}
|
|
|
|
internal static bool TryParseJson<T>(this string @this, out T result)
|
|
{
|
|
var success = true;
|
|
var settings = new JsonSerializerSettings
|
|
{
|
|
Error = (sender, args) =>
|
|
{
|
|
success = false;
|
|
args.ErrorContext.Handled = true;
|
|
},
|
|
MissingMemberHandling = MissingMemberHandling.Ignore
|
|
};
|
|
result = JsonConvert.DeserializeObject<T>(@this, settings);
|
|
return success;
|
|
}
|
|
}
|
|
}
|