namespace Rizu.Core; /* * JsonShim creates a single place that JSON APIs get called from, to avoid having to manually write precompiler directives every time. * Never call a JSON package directly, always call via JsonShim. */ #if MONOMOD using UnityEngine; using System; #else using System.Text.Json; #endif public class JsonShim { public static string Serialize(object Target) { #if MONOMOD return JsonUtility.ToJson(Target); #else return JsonSerializer.Serialize(Target); #endif } public static T Deserialize(string data) { #if MONOMOD return JsonUtility.FromJson(data); #else return JsonSerializer.Deserialize(data); #endif } } #if MONOMOD [AttributeUsage(AttributeTargets.Property | System.AttributeTargets.Field, AllowMultiple = false)] public class JsonIncludeAttribute : Attribute { } #endif