Is there a module which can pretty print json format data in Nodejs? - V2EX
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 4913 次点击
    这是一个创建于 2796 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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:5: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     Solana     5667 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 29ms UTC 02:07 PVG 10:07 LAX 18:07 JFK 21:07
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86