One downside of JSON is it is not very readable, especially when used as a configuration language.
To fix this, we can embed JSON data in a markdown file using a certain format that is readable and commentable. A script takes the markdown file and converts it into one or more JSON files.
Define the start of a JSON file in your markdown with a header that is a link to a local json file, such as:
## [my_config.json](my_config.json)
Bulleted lists underneath that section are the keys and values for your JSON file. Similar to YAML, a colon separates key/values, and you don't need quotes. Any text outside the bulleted list are comments.
## [my_config.json](my_config.json)
These are the keys and values for the above JSON file:
* key1: value1
* key2: value2
Sub-headers below the JSON file header denote the start of nested objects.
## [my_config.json](my_config.json)
These are the keys and values for this JSON file:
* key1: value1
* key2: value2
### my_subobject
Everything in this section is set under the `my_subobject` key:
* subkey1: value1
* subkey2: value2
The above JSON is equivalent to a more compact nested list:
## [my_config.json](my_config.json)
* key1: value1
* key2: value2
* my_subobject:
* subkey1: value1
* subkey2: value2
You can also reduce nesting with a list by using a JSON path:
## [my_config.json](my_config.json)
* key1: value1
* key2: value2
* my_subobject.subkey1: value1
* my_subobject.subkey2: value2
If you need a key with dots in it, simply quote each part: "parent.key"."child.key": value
The following is an example of a readable NPM package configuration that generates a package.json
.
- name: uzu-cell
- version: 0.0.1
- description: Functional, observable, & reactive data cells
- main: index.js
- keywords: [cell, frp, reactive]
- author: [email protected]
- license: MIT
- bugs.url: https://github.com/uzujs/uzu-cell/issues
Run all tests with npm run test
- test:
standard && tape test/index.js | tap-spec
- curry: 1.2.0
- ramda: 0.24.1
- standard: 10.0.3
- tap-spec: 4.1.1
- tape: 4.8.0