Created
June 3, 2019 12:55
-
-
Save kwestground/ab4cb1792304ca0675a3cda57993ec28 to your computer and use it in GitHub Desktop.
Json.NET Hana Decimal to decimal converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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