Which Sphinx code-block language to use for JSON

JayhawksFan93 picture JayhawksFan93 · Nov 23, 2010 · Viewed 19.4k times · Source

I am using Sphinx to document a web service. I would like to show a formatted JSON web response using the code-block directive, which Spinx does via Pygments, but JSON doesn't have a syntax highlighter in Pygments. What language do you suggest I specify instead? HTML? JavaScript?

.. code-block:: javascript

    {
      "name": "roger",
      "score": 100
    }

Answer

The Aelfinn picture The Aelfinn · Jul 1, 2016

I am using Sphinx 1.4.2 which includes a Pygments lexer called "json". This is available out-of-the-box by default. To use:

.. code-block:: json

    {
        "key": "value",
        "key2": "value2",
        ...
    }