MinecraftRecipeRevamper/MinecraftRecipeSerializer.cs

26 lines
No EOL
737 B
C#

using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace RecipeRevamper;
public class MinecraftRecipeSerializer
{
private static readonly JsonSerializerSettings _settings = new JsonSerializerSettings
{
ContractResolver = new LowerCaseContractResolver(),
NullValueHandling = NullValueHandling.Ignore
};
public static string SerializeObject(object o)
{
return JsonConvert.SerializeObject(o, Formatting.Indented, _settings);
}
public class LowerCaseContractResolver : DefaultContractResolver
{
protected override string ResolvePropertyName(string propertyName)
{
return propertyName.ToLower();
}
}
}