Skip to content

JSON

"JSON (JavaScript Object Notation) is a lightweight data-interchange format." - https://www.json.org/

See also

  • toml: "TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics."
  • yaml: Better human readability, more options.

Is YAML a superset of JSON?

Many people say that JSON is a subset of YAML, but that is not strictly true. See https://metacpan.org/pod/JSON::XS#JSON-and-YAML

Here's an example of json that does not work as yaml:

$ sed 's/\t/--->/g' break-yaml.json
--->{
--->--->"list": [
--->--->--->{},
--->--->--->{}
--->--->]
--->}
$ jq -c . break-yaml.json
{"list":[{},{}]}
$ json-to-yaml.py break-yaml.json
list:
- {}
- {}
$ yaml-to-json.py break-yaml.json
ERROR: break-yaml.json could not be parsed
while scanning for the next token
found character '\t' that cannot start any token
in "break-yaml.json", line 1, column 1
$ sed 's/\t/    /g' break-yaml.json | yaml-to-json.py
{"list": [{}, {}]}