Skip to content

Instantly share code, notes, and snippets.

@kwestground
Created June 3, 2019 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwestground/ab4cb1792304ca0675a3cda57993ec28 to your computer and use it in GitHub Desktop.
Save kwestground/ab4cb1792304ca0675a3cda57993ec28 to your computer and use it in GitHub Desktop.
Json.NET Hana Decimal to decimal converter
using System;
using Newtonsoft.Json;
using Sap.Data.Hana;
public class HanaDecimalJsonConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value == null) return;
writer.WriteValue(((HanaDecimal)value).ToDecimal());
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
return null;
}
public override bool CanWrite => true;
public override bool CanRead => false;
public override bool CanConvert(Type objectType)
{
return typeof(HanaDecimal) == objectType;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment