Skip to content

Instantly share code, notes, and snippets.

@cowboy
Last active August 29, 2015 13:56
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cowboy/8829466 to your computer and use it in GitHub Desktop.
Save cowboy/8829466 to your computer and use it in GitHub Desktop.
Why do we keep having the "comments in JSON" discussion? Just use YAML.
{
# this is a comment
"a": "hello",
# this is another comment
"b": -1,
"c": [
true,
"test",
null
],
# yet another comment
"d": {
"x": 1,
"y": 2
}
}
# this is a comment
a: hello
# this is another comment
b: -1
c:
- true
- "test"
- null
# yet another comment
d:
x: 1
y: 2
@cowboy
Copy link
Author

cowboy commented Feb 5, 2014

See how a YAML parser parses:

@cowboy
Copy link
Author

cowboy commented Feb 5, 2014

If you want to use a YAML configuration file on the server/command line, there are YAML libraries for most languages. For example, Grunt's grunt.file.readYAML method uses the npm js-yaml module.

If you need to use data stored in YAML in the browser, you can compile all your YAML files into JSON before sending them to the client, as part of your build process with a Grunt plugin like grunt-yaml (I haven't tested it, personally).

@wayneseymour
Copy link

May have to copy this idea!

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment