mirror of
https://github.com/Raymonf/whack.git
synced 2025-02-15 18:02:39 +01:00
31 lines
822 B
C#
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));
|
|
}
|
|
}
|
|
}
|