# HG changeset patch # User Oleksandr Gavenko # Date 1487500408 -7200 # Node ID bb22372fc204e2886bb226350b8a77d89246222a # Parent b9bf144836b855bc0bc3d7c1466f7c0187d2fc5d Pretty print json. diff -r b9bf144836b8 -r bb22372fc204 prettyprint.rst --- a/prettyprint.rst Sat Feb 18 16:16:35 2017 +0200 +++ b/prettyprint.rst Sun Feb 19 12:33:28 2017 +0200 @@ -11,15 +11,24 @@ Code formatter, beautifier, pretty printer. - http://en.wikipedia.org/wiki/Pretty-printer - Wiki article. +http://en.wikipedia.org/wiki/Pretty-printer + Wiki article on pretty printing. -xml. +json ==== -tidy. ------ -:: +With Python 2.6+:: + + $ python -m simplejson.tool $FILE + +In terminal you can add color support with ``pygmentize``:: + + $ curl -s http://.../... | python -m simplejson.tool | pygmentize -l json + +xml +=== + +With tidy:: $ tidy -xml -i -utf8 -o out.xml in.xml @@ -27,32 +36,24 @@ C-x h C-x c utf-8 C-u M-| tidy -q -xml -i -utf8 - - http://tidy.sourceforge.net - Home page. - http://www.emacswiki.org/cgi-bin/wiki/tidy.el - Emacs bindings. - -xmllint. --------- -:: +With xmllint:: $ xmllint --format file.xml -or in Emacs: +or in Emacs:: : C-x h C-u M-| xmllint --format - -Emacs and nxml. ---------------- - -You need introduce line-breaks and then:: +With Emacs and nxml you need introduce line-breaks and then:: C-x h C-M-\ -xmlindent. ----------- - - http://xmlindent.sourceforge.net/ +http://tidy.sourceforge.net + Home page. +http://www.emacswiki.org/cgi-bin/wiki/tidy.el + Emacs bindings. +http://xmlindent.sourceforge.net/ + xmlindent home page. c/c++/java/c#. ============== @@ -88,6 +89,6 @@ Perl. ===== - http://perltidy.sourceforge.net/ - Home page. +http://perltidy.sourceforge.net/ + Home page.