using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
public static void Main()
var json1 = "{'$type': 'this is the type', 'planNumber': 'this is the plan number', '$myProp': 'this is my prop'}";
var obj1 = JsonConvert.DeserializeObject<myobject>(json1, new Newtonsoft.Json.JsonSerializerSettings());
Console.WriteLine("Sample 1");
Console.WriteLine($"Type: {obj1.Type}");
Console.WriteLine($"Plan Number: {obj1.PlanNumber}");
Console.WriteLine($"My Prop: {obj1.MyProp}");
var json2 = "{'planNumber': 'this is the plan number', '$type': 'this is the type', '$myProp': 'this is my prop'}";
var obj2 = JsonConvert.DeserializeObject<myobject>(json2, new Newtonsoft.Json.JsonSerializerSettings());
Console.WriteLine("Sample 2");
Console.WriteLine($"Type: {obj2.Type}");
Console.WriteLine($"Plan Number: {obj2.PlanNumber}");
Console.WriteLine($"My Prop: {obj2.MyProp}");
Console.WriteLine("Finished!");
[DataMember(Name="$type")]
public string Type {get;set;}
[DataMember(Name="planNumber")]
public string PlanNumber {get;set;}
[DataMember(Name="$myProp")]
public string MyProp {get;set;}