V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
bluetoy
V2EX  ›  Node.js

Is there a module which can pretty print json format data in Nodejs?

  •  
  •   bluetoy · 2018-04-15 22:09:16 +08:00 · 4451 次点击
    这是一个创建于 2451 天前的主题,其中的信息可能已经有所发展或是发生改变。

    As the title describe,

    Can you help me recomend a module?

    thanks!

    12 条回复    2018-04-16 12:17:42 +08:00
    lihongjie0209
        1
    lihongjie0209  
       2018-04-15 22:33:53 +08:00
    yes, a module with thousands of dependency
    klesh
        2
    klesh  
       2018-04-15 22:36:36 +08:00 via Android
    JSON.stringify(o, null, 2)
    Lxxyx
        3
    Lxxyx  
       2018-04-15 22:48:16 +08:00 via Android
    楼上+1,原生支持
    chengluyu
        4
    chengluyu  
       2018-04-15 22:51:14 +08:00
    `JSON.stringify` or `require('util').inspect`
    SuperMild
        5
    SuperMild  
       2018-04-15 22:54:16 +08:00
    Your English is so good, why not search that by yourself?

    I just put your title (as it is) into google, just 1 second or less later, the first item of the result is what you want.
    ynyounuo
        6
    ynyounuo  
       2018-04-15 23:02:04 +08:00
    英语不好真的不用硬来,本来就是中文社区。
    SuperMild
        8
    SuperMild  
       2018-04-15 23:33:25 +08:00   ❤️ 1
    @bluetoy 原来如此,推荐你一个好方案!在 chrome 里安装 google 输入法插件,在 firefox 里搜一下 pinyin 之类的关键词也有插件的,我就是这样用,系统级别的输入法我就不装了,因为在 linux 里我基本上都是在网页里才需要中文输入法。
    autoxbc
        9
    autoxbc  
       2018-04-16 00:07:14 +08:00   ❤️ 1
    http://jsbeautifier.org/
    https://www.npmjs.com/package/js-beautify


    CLI Options:
    -f, --file Input file(s) (Pass '-' for stdin)
    -r, --replace Write output in-place, replacing input
    -o, --outfile Write output to file (default stdout)
    --config Path to config file
    --type [js|css|html] ["js"]
    -q, --quiet Suppress logging to stdout
    -h, --help Show this help
    -v, --version Show the version

    Beautifier Options:
    -s, --indent-size Indentation size [4]
    -c, --indent-char Indentation character [" "]
    -t, --indent-with-tabs Indent with tabs, overrides -s and -c
    -e, --eol Character(s) to use as line terminators.
    [first newline in file, otherwise "\n]
    -n, --end-with-newline End output with newline
    --editorconfig Use EditorConfig to set up the options
    -l, --indent-level Initial indentation level [0]
    -p, --preserve-newlines Preserve line-breaks (--no-preserve-newlines disables)
    -m, --max-preserve-newlines Number of line-breaks to be preserved in one chunk [10]
    -P, --space-in-paren Add padding spaces within paren, ie. f( a, b )
    -E, --space-in-empty-paren Add a single space inside empty paren, ie. f( )
    -j, --jslint-happy Enable jslint-stricter mode
    -a, --space-after-anon-function Add a space before an anonymous function's parens, ie. function ()
    -b, --brace-style [collapse|expand|end-expand|none][,preserve-inline] [collapse,preserve-inline]
    -u, --unindent-chained-methods Don't indent chained method calls
    -B, --break-chained-methods Break chained method calls across subsequent lines
    -k, --keep-array-indentation Preserve array indentation
    -x, --unescape-strings Decode printable characters encoded in xNN notation
    -w, --wrap-line-length Wrap lines at next opportunity after N characters [0]
    -X, --e4x Pass E4X xml literals through untouched
    --good-stuff Warm the cockles of Crockford's heart
    -C, --comma-first Put commas at the beginning of new line instead of end
    -O, --operator-position Set operator position (before-newline|after-newline|preserve-newline) [before-newline]
    Kongtou
        10
    Kongtou  
       2018-04-16 00:11:40 +08:00 via Android
    haha,interesting
    jasonchn
        11
    jasonchn  
       2018-04-16 00:16:13 +08:00 via Android
    这英文太尬了。。。
    bluetoy
        12
    bluetoy  
    OP
       2018-04-16 12:17:42 +08:00 via Android
    @SuperMild 确实有用
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1211 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 23:33 · PVG 07:33 · LAX 15:33 · JFK 18:33
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.