I have a contract defined like this:
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
public class Foo
{
[JsonProperty("type")]
public int Type { get; set; }
[JsonProperty("value")]
public JObject Value { get; set; }
}
Type
property defines the type which Value
is deserialized to.
This contract is used by 2 separate microservices.
One of microservices wants to switch to System.Text.Json
instead of Newtonsoft
while another microservice will still use Newtonsoft
for some time.
It’s fine with Type
property – I just add JsonPropertyName("type")
attribute from System.Text.Json
.
But what to do with Value
property? It’s type is already a JObject
– type defined in Newtonsoft
. What is a correct way to handle it?
8