[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Omaha.pm] pretty JSON



Cool. I've been using   xmllint --format   to make XML pretty for years. JSON::XS ships with json_xs, which does the same thing for JSON.

BEFORE:
[{"body":{"general":{"date_discontinued":"","is_assembly":false,"is_hidden":false,"description":{"en":"LAMP EMD 75...

AFTER:
[
   {
      "body" : {
         "cost" : {
            "default_rate" : "W",
            "week_price" : {
               "USD" : 0
            },
            "day_price" : {
               "USD" : 0
            }
         },
         ...

This is also handy for piping web service URLs to my human eyeballs:     :)

   curl 'http://foo.bar/baz' | json_xs

Jay Hannah
Senior Developer / Consultant
http://www.iinteractive.com
Email: jay.hannah@iinteractive.com