Live data from Hacker News

Pretty-printing JSON and XML on Mac OSX

richardlog.com

1–10 of 11 posts

Re: Pretty-printing JSON and XML on Mac OSX

#3

Hey! Why not use https://github.com/nicksieger/jsonpretty for pretty printing JSON?

Because these work out-of-the-box on an installation of Snow Leopard or Lion - or in fact, any machine with python 2.6 and/or libxml2, which includes the latest Ubuntu LTS release.

There's definitely better tools out there if you're willing to install something - but these are great when you're in a pinch.

Re: Pretty-printing JSON and XML on Mac OSX

#5
Just be aware that xmllint cleans up XML as well as formatting it, which can in rare circumstances cause some confusion.

So if the incoming XML had an empty tag specified as xmllint will turn it into . If you're specifically looking for for some reason, then that could trip you up.

Shouldn't matter 99% of the time though.

Re: Pretty-printing JSON and XML on Mac OSX

#7
post #6

You could also just pipe it back into the clipboard with | pbcopy :) A neat set of tricks, hopefully they'll replace jsonlint.com in my brain, and soon :)

pbcopy/pbpaste are handy enough to point out on their own merit. Handy little timesavers.
Post reply on HN