pretty-print JSON using JavaScript

后端 未结 24 1761
一向
一向 2020-11-21 06:45

How can I display JSON in an easy-to-read (for human readers) format? I\'m looking primarily for indentation and whitespace, with perhaps even colors / font-styles / etc.

24条回答
  •  春和景丽
    2020-11-21 07:21

    This is nice:

    https://github.com/mafintosh/json-markup from mafintosh

    const jsonMarkup = require('json-markup')
    const html = jsonMarkup({hello:'world'})
    document.querySelector('#myElem').innerHTML = html
    

    HTML

    
    
提交回复
热议问题