ARTICLE AD BOX
I would like to use JSON as the format for my program's configuration file. When writing the file to disk, it should contain comments that describe each field. These comments should be controlled through an attribute if possible.
public class Person { [JsonComment("Name of the person")] public string Name { get; set; } [JsonComment("Age of the person")] public int Age { get; set; } }And the output should look like this:
{ /*Name of the person*/ "Name": "Jack", /*Age of the person*/ "Age": 22 }Some previous questions show how to write comments after the value, eg after "Jack". I would like to write the comment before the property name, eg before "Name". Using Json.NET or System.Text.Json or some other library, is it possible to format comments in this way?
