jsonc

JSON has a compact format, which is difficult to read. The jsonc format applies syntax highlighting of JSON tokens and indentation.

Example: name and value pairs to formatted JSON

env | grep JAVA | gutenfmt --output jsonc

Output:

{
  "JAVA_HOME": "/usr/lib/jvm/java-8-openjdk-amd64",
  "JAVA_OPTS": "-server -Xmx512m"
}

Example: compact JSON to formatted JSON

jq -c -M . docs/data/glossary.json | gutenfmt --output jsonc

Output:

{
  "glossary": {
    "GlossDiv": {
      "GlossList": {
        "GlossEntry": {
          "Abbrev": "ISO 8879:1986",
          "Acronym": "SGML",
          "GlossDef": {
            "GlossSeeAlso": [
              "GML",
              "XML"
            ],
            "para": "A meta-markup language, used to create markup languages such as DocBook."
          },
          "GlossSee": "markup",
          "GlossTerm": "Standard Generalized Markup Language",
          "ID": "SGML",
          "SortAs": "SGML"
        }
      },
      "title": "S"
    },
    "title": "example glossary"
  }
}

Note that jq has plenty of formatting options, which excel the ones provided by gutenfmt. However, this example illustrates that gutenfmt is capable of formatting complex JSON prettily.