public static void Main()
Console.WriteLine("Try serialize");
var testObject = new TestObject("SomeValue");
var testObjectJson = JsonConvert.SerializeObject(testObject);
Console.WriteLine($"Serialized object: '{testObjectJson}'");
Console.WriteLine("Try serialize null");
var testObject2 = new TestObject(null);
var testObject2Json = JsonConvert.SerializeObject(testObject2);
Console.WriteLine($"Serialized object: '{testObject2Json}'");
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
[JsonProperty(Required = Required.Always)]
public string SomeProperty { get; }
public TestObject(string someProperty)
SomeProperty = someProperty;