I\'m writing a tool to read JSON files. I\'m using the NewtonSoft tool to deserialize the JSOn to a C# class. Here\'s an example fragment:
\"name\": \"Fubar
If you're using System.Text.Json
, the equivalent attribute is JsonPropertyName:
[JsonPropertyName(".net version")]
public string DotNetVersion { get; set; }
Example below:
public class Data
{
public string Name { get; set; }
[JsonPropertyName(".net version")]
public string DotNetVersion { get; set; }
[JsonPropertyName("binding type")]
public string BindingType { get; set; }
}
// to deserialize
var data = JsonSerializer.Deserialize(json);