Re: [racket] Json pretty-print

2013-04-16 Thread Grant Rettke
On Tue, Apr 16, 2013 at 4:23 PM, Nick Shelley wrote: > The thing is, the system call to python works for our needs and is easier > than rolling my own. FWIW it is so pleasant in Python that at work the .NET guys use Python to do the same thing! :) Racket Users list: http

Re: [racket] Json pretty-print

2013-04-16 Thread Nick Shelley
First off, thanks Carl and Danny for the code. The thing is, the system call to python works for our needs and is easier than rolling my own. The reason I started this thread in the first place is because it seems like outputting human-readable json is common and often desired (see the upvotes in t

Re: [racket] Json pretty-print

2013-04-16 Thread Eli Barzilay
That's not really relevant in this case: there is no problem here comparing the keys since they are all symbols. 10 minutes ago, Danny Yoo wrote: > Racket provides a generic order predicate: see data/order: > > http://docs.racket-lang.org/data/Orders_and_Ordered_Dictionaries.html > > For e

Re: [racket] Json pretty-print

2013-04-16 Thread Danny Yoo
Racket provides a generic order predicate: see data/order: http://docs.racket-lang.org/data/Orders_and_Ordered_Dictionaries.html For example, https://gist.github.com/dyoo/5398549#file-pretty-print-json-rkt-L5 https://gist.github.com/dyoo/5398549#file-pretty-print-json-rkt-L12 ht

Re: [racket] Json pretty-print

2013-04-16 Thread Eli Barzilay
40 minutes ago, Nick Shelley wrote: > I'm pretty sure what I want is the easy thing. We have data > represented as json, and we want changes to it to be easy to see in > a difftool. Everything on one line makes this hard. We just have a > bunch of nested arrays and dictionaries that need to be tabb

Re: [racket] Json pretty-print

2013-04-16 Thread Danny Yoo
Similar forking going on. :) Here's another version (based on the json library in the standard library, but hacked up a bit): https://gist.github.com/dyoo/5398549 I think the point is: it should be very easy to do this; it's just a matter of knowing what behavior you want. _

Re: [racket] Json pretty-print

2013-04-16 Thread Carl Eastlund
Nick, I've just built pretty-printing for JSON in a Gist you can see here: https://gist.github.com/carl-eastlund/5398440 It's built on top of my own "stylish printing" library, mischief/stylish, that you can install by running: raco pkg install mischief I'll add this to the mischief packag

Re: [racket] Json pretty-print

2013-04-16 Thread Nick Shelley
I'm pretty sure what I want is the easy thing. We have data represented as json, and we want changes to it to be easy to see in a difftool. Everything on one line makes this hard. We just have a bunch of nested arrays and dictionaries that need to be tabbed and newlined with no regard to width. As

Re: [racket] Json pretty-print

2013-04-16 Thread Sean McBeth
I've had good luck porting simple Python examples to Racket. Perhaps you could start with the Python code that works as you expect, port it to Racket, then refactor it to more Rackety ways: http://hg.python.org/cpython/file/cc0e72082e52/Lib/json On Tue, Apr 16, 2013 at 1:54 PM, Eli Barzilay wrot

Re: [racket] Json pretty-print

2013-04-16 Thread Eli Barzilay
Just now, Nick Shelley wrote: > In talking with an experienced Racketeer, I realized that > pretty-print has a specific meaning in Racket that takes width into > account. That's exactly what I thought you were talking about. Doing it from scratch seems wrong, and I thought that the right way to d

Re: [racket] Json pretty-print

2013-04-16 Thread Nick Shelley
In talking with an experienced Racketeer, I realized that pretty-print has a specific meaning in Racket that takes width into account. What I really want is json with properly placed newlines and tabs (or spaces). I'm willing to take a stab at it if it doesn't exist. I just wanted to make sure I w

Re: [racket] Json pretty-print

2013-04-16 Thread Nick Shelley
I ended up just doing a system call to Python as suggested here: http://stackoverflow.com/questions/352098/how-to-pretty-print-json-from-the-command-line . When one of my coworkers (who I've been trying to convince that Racket is a real language) reviewed my code, he laughed at that line because h

[racket] Json pretty-print

2013-04-13 Thread Nick Shelley
Is there a way to get formatted json output to a file? I couldn't figure out how to get pretty-print hooked in with write-json. I'm probably just missing something simple. Racket Users list: http://lists.racket-lang.org/users