Beyond that we need to see the JSON you are trying to deserialize -- ie.
How to add using system.text.json. Var je_root JsonSerializerDeserializejsonstr. Record Userstring Name string Occupation MyDate DateOfBirth. Use Newtonsoft JObject to add properties to your Json Object.
This library allows object serialization but this is too complex for my needs as I would prefer manipulating the DOM without the need of creating corresponding classes in my code. In JsonNET I would have used SerializeObject to create JSON meant for a file on disk or messaging platform like Azure Service Bus. MyType obj new Message Hello World.
Newtonsoft solution Now the easiest solution would be to just switch over to Newtonsoft by adding a reference to MicrosoftAspNetCoreMvcNewtonsoftJson and then do this. Heres a simple example of how to use it to serialize and deserialize JSON to and from NET object types. In all the above scenarios adding the AddNewtonsoftJson call to the end means that were going to use the NewtonsoftJson APIs over the default SystemTextJson implementation.
In the near future we will update that serializer to also use SystemTextJson but for now it cant be changed. Var json JsonSerializerDeserializejson as JsonElement. Var user new UserJohn Doe gardener new MyDate1995 11 30.
Int myvalue je_rootGetPropertyMyPropertyGetPropertyMySubPropertyGetInt32. This article shows how to use the SystemTextJson namespace to serialize to and deserialize from JavaScript Object Notation JSON. If youre porting existing code from NewtonsoftJson see How to migrate to SystemTextJson.
For the below frameworks SystemTextJson is available through NuGet PackageNET Standard 20 and NET Framework 472 and NET Core 20 21 and 22. A minimal reproducible example. You will need to add a parameterless constructor.