1
0
mirror of https://github.com/Raymonf/whack.git synced 2025-02-15 01:42:34 +01:00
whack/WTT/UAssetAPI/JSON/FStringJsonConverter.cs
2022-09-28 18:39:41 -04:00

31 lines
822 B
C#

using Newtonsoft.Json;
using System;
using UAssetAPI.UnrealTypes;
namespace UAssetAPI.JSON
{
public class FStringJsonConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return objectType == typeof(FString);
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
writer.WriteValue((value as FString)?.Value);
}
public override bool CanRead
{
get { return true; }
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.Value == null) return null;
return new FString(Convert.ToString(reader.Value));
}
}
}