If I defined a record that implements an interface with an additional property the interface properties are not serialized by json.net. How do I get json.net to serialize those interface properties. Here is an example
open Newtonsoft.Json
type IRecord =
abstract member id : string
type ARec = {
Name : string
} with
interface IRecord with
member this.id = this.Name
let aRec = {Name = "John"}
Both JsonConvert.SerializeObject aRec
and JsonConvert.SerializeObject (aRec :> IRecord)
result in {"Name":"John"}
but I expected {"Name":"John"; "id":"John"}
I tried adding ShouldSerializeid
to the interface but that made no difference.