[racket] Json pretty-print
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 do it is to
hook into the pretty-printer that we already have.
> What I really want is json with properly placed newlines and tabs
> (or spaces).
This sounds somewhere between very easy (if all you want is
newlines+indentation up to a specific level) to something more
complicated if you want to control other aspects like spaces around
colons, sort keys in tables, etc.
> I'm willing to take a stab at it if it doesn't exist. I just wanted
> to make sure I wasn't missing it somewhere (which happens often with
> me).
If you can summarize the python-equivalent features in a rackety way,
I can see if it's easy to add them to our printer.
IIUC, this interface means that `write-json' would get a bunch of
additional keywords, but I'm not sure about it, since in Racket
`write' usually refers to something closer to serializing a value in a
readable way rather than printing it in a readable way. So maybe the
right thing is to add a `print-json' function even if it duplicates
the functionality of `write-json'.
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!