Trying to deserialize a simple JSON string to a Rules object in .NET Core 3.1
using System.Text.Json;
namespace Whatever
{
public class Rules
{
public SyncResponse SyncResponse;
public Rules Load()
{
var text = File.ReadAllText("/path/to/json.txt");
var options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
ReadCommentHandling = JsonCommentHandling.Skip
};
var result = JsonSerializer.Deserialize<Rules>(text, options);
return result;
}
}
public class SyncResponse
{
public string Status;
}
}
The content of the JSON file looks as follows
/* Some comment here */
{"SyncResponse":{"status":"success"}}
However; when I call Rules.Load(), it returns an instance of Rules, but SyncResponse is null. Can anyone point out what I'm doing wrong?