I have the following:
public class MyClass : SuperClass { [JsonProperty] public virtual string Id { get; set; } } public abstract class SuperClass { public int GetHashCode() {
I can not change SuperClass . When I move on to serializing Json using JsonNet, I will do something like this:
JsonSerializerSettings serializer = new JsonSerializerSettings { //serializer settings }; var jsonNetResult = new JsonNetResult { Data = myClass, SerializerSettings = serializer }; return jsonNetResult;
Obviously, this will not be serialized by GetHashCode() . If I go:
var jsonNetResult = new JsonNetResult { Data = myClass.GetHashCode(), SerializerSettings = serializer };
It serializes the value correctly, is there some kind of serialization parameter that I can use to tell it to include GetHashCode() ?
Edit: I have to add that right now I'm only creating a property for this, i.e.
[JsonProperty] public virtual int GetHashCodeJson { get { return GetHashCode(); }
source share