Loading ...
Sorry, an error occurred while loading the content.

21707Re: [ydn-javascript] Any JSON Pretty-Printers Out There?

Expand Messages
  • Randall R Schulz
    Dec 2, 2007
      On Sunday 02 December 2007 18:39, Ask Bjørn Hansen wrote:
      > On Nov 30, 2007, at 10:50 AM, Randall R Schulz wrote:
      > > Compact JSON, as most web apps produce it, is very hard to read.
      > >
      > > Does anyone here know of a reformatter / pretty-printer for JSON?
      > > I'd prefer a command-line tool that runs on (or can be compiled
      > > for) Linux.
      > > If necessary, I'd use an on-line tool.
      >
      > As someone else said, a few words of Perl:
      >
      > perl -MJSON -e '$j=JSON->new(pretty=>1); $/=undef; print $j-
      >
      > >objToJson($j->jsonToObj(<>))'
      >
      > You can either pipe in "ugly" JSON on stdin or specify a file as a
      > parameter at the end. Stdout will have the pretty JSON.

      Perl's not my thing.

      I took your command and used the URL that freyfogle gave to get JSON.pm
      (and JSON/Parser.pm, which it refers to and without which it will not
      run) and I when I invoke it (the command above) I get a pile (246 lines)
      of diagnostics. Here are the first few:

      Bareword found where operator expected at JSON/Parser.pm line 4, near ""stylesheet" href"
      (Missing operator before href?)
      Bareword found where operator expected at JSON/Parser.pm line 4, near ""/s/style.css" type"
      (Missing operator before type?)
      Bareword found where operator expected at JSON/Parser.pm line 7, near "</head"
      (Might be a runaway multi-line // string starting on line 6)
      (Missing operator before head?)


      What's the right way to use this stuff? I'm running on Linux (SuSE Linux 10.0)


      > - ask


      Thanks.

      Randall Schulz
    • Show all 10 messages in this topic