How do I add comments to Json.NET output?

后端 未结 4 1590
攒了一身酷
攒了一身酷 2021-02-18 21:56

Is there a way I can automatically add comments to the serialised output from Json.NET?

Ideally, I\'d imagine it\'s something similar to the following:

pub         


        
4条回答
  •  南旧
    南旧 (楼主)
    2021-02-18 22:12

    As @RoToRa already said, JSON does not permit comments.

    If you still want comments, and you want to output correct JSON, you could just make the comments part of the actual JSON data by changing the data layout. For example:

    {
        "MyString": {
            "doc":   "My documentation string",
            "value": "Test"
        } 
    }
    

提交回复
热议问题