注释掉简单 json 中的行以放置一些描述
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45974471/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
comment out lines in simple json to put some description
提问by Rehan Ch
How do I add comments in a simple JSON file which be read from s3 in AWS. This is my JSON file.
如何在从 AWS 中的 s3 读取的简单 JSON 文件中添加注释。这是我的 JSON 文件。
{
"Parameters": {
"KeyPairName": "mykey",
"InstanceTypes": "t2.micro",
"prodImageIds": "ami-d7abd1b8",
"testImageIds": "ami-e41b618b",
"devImageIds": "ami-8f8afde0"
},
"StackPolicy": {
"Statement": [
{
"Effect": "Allow",
"NotAction": "Update:Delete",
"Principal": "*",
"Resource": "*"
}
]
}
}
回答by whites11
JSON specification doesn't include comments of any kind. You can simply add a standard key/value pair with a key that gets ignored by the application (maybe _comment) but there is no way to insert a proper comment.
JSON 规范不包含任何类型的注释。您可以简单地添加一个标准键/值对,其中包含一个被应用程序忽略的键(可能_comment),但无法插入正确的注释。
Here the spec details: http://www.json.org/
这里的规范详细信息:http: //www.json.org/
回答by Paco Barter
I usually do something like adding
"------------------------------------------" : "------------------------------------------"to visually separate "sections".
我通常会做一些事情,比如添加
"------------------------------------------" : "------------------------------------------"视觉上分开的“部分”。

