https://stackoverflow.com/questions/76472555/deserialize-empty-object-with-newtonsoft-json

CSharp · Console

/Program.cs

using System;
using Newtonsoft.Json.Schema;
using Newtonsoft.Json.Schema.Generation;
using Newtonsoft.Json.Linq;
					
public class Program
{
	static JSchemaGenerator generator = new JSchemaGenerator();
	static JSchema schema = generator.Generate(typeof(Temp));
	public static void Main()
	{
		var jsons = new[] {
			"{}",
			"{'Field1': \"1\"}",
			"{'Field1': \"1\", 'Field2': 2}",
			"{'Field1': \"1\", 'Field2': 2, 'Field3': 'false'}",
			"{'Field1': \"1\", 'Field2': 2, 'Field3': false}",
			"{'Field1': \"1\", 'Field2': 2, 'Field3': false, 'Field4': 4.0}",
		};
		
		foreach(var json in jsons)
		{
			var semiParsedJson = JObject.Parse(json);
			Console.WriteLine($"{json} is valid: {semiParsedJson.IsValid(schema)}");
		}
	}
}

public class Temp 
{
    public string Field1 { get; set; }
    public int Field2 { get; set; }
    public bool Field3 { get; set; }
}
;