How do I add comments in a simple JSON file which be read from s3 in AWS. This is my JSON file.
{
"Parameters": {
"KeyPairName": "mykey",
"InstanceTypes": "t2.micro",
"prodImageIds": "ami-d7abd1b8",
"testImageIds": "ami-e41b618b",
"devImageIds": "ami-8f8afde0"
},
"StackPolicy": {
"Statement": [
{
"Effect": "Allow",
"NotAction": "Update:Delete",
"Principal": "*",
"Resource": "*"
}
]
}
}
No, JSON is a data-only format. Comments in the form //, #, or /* */, which are used in popular programming languages, are not allowed in JSON. You can add comments to JSON as custom JSON elements that will hold your comments, but these elements will still be data.
If you're having trouble adding comments to your JSON file, there's a good reason: JSON doesn't support comments.
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.
Here the spec details: http://www.json.org/
I usually do something like adding
"------------------------------------------" : "------------------------------------------"
to visually separate "sections".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With