We are using a NuGet package (NJsonSchema) which helps to convert JSON to C# class easily, if you want to permanently use it in your C# Code, you can use it.
Here are the steps to use NJsonSchema in your C# project to convert JSON string or object into C# Model:
string json = "{ "name":"John", "age":30, "car":null }";
var schemaFromFile = JsonSchema.FromSampleJson(json);
var classGenerator = new CSharpGenerator(schemaFromFile, new CSharpGeneratorSettings
{
ClassStyle = CSharpClassStyle.Poco,
});
//generated Class file
var codeFile = classGenerator.GenerateFile();