Reuse various serialization code

This commit is contained in:
Wojtek Figat
2024-03-08 14:26:48 +01:00
parent f4a352ec8d
commit 584c073df1
3 changed files with 23 additions and 118 deletions

View File

@@ -246,15 +246,7 @@ namespace FlaxEngine.Json
/// <returns>The output json string.</returns>
public static string Serialize(object obj, bool isManagedOnly = false)
{
Type type = obj.GetType();
var cache = isManagedOnly ? CacheManagedOnly.Value : Cache.Value;
Current.Value = cache;
cache.WriteBegin();
cache.SerializerWriter.Serialize(cache.JsonWriter, obj, type);
cache.WriteEnd();
return cache.StringBuilder.ToString();
return Serialize(obj, obj.GetType(), isManagedOnly);
}
/// <summary>