Shawn Wagner <shawnw.mobile@gmail.com>
Want JSON that’s easier for humans to read instead of the compact form produced by write-json and jsexpr->string ? Look no further!
Pure racket, very similar to JQ output (Except for adding a space before colons in objects).
procedure
( jsexpr->pretty-json js)→string?
js:jsexpr?
procedure
js:jsexpr?
procedure
( format-json json)→string?
json:string?
procedure
( format-json/bytes json)→bytes?
json:bytes?
procedure
( pretty-print-jsexpr js[out])→void?
js:jsexpr?
procedure
( pretty-print-json json[out])→void?
json:string?
procedure
( pretty-print-json/bytes json[out])→void?
json:bytes?
Tries to use less vertical space by printing small arrays and objects on a single line. Experimental and not very well tested.
parameter
( pretty-print-json-line-width)→exact-positive-integer?
width:exact-positive-integer?= 80
parameter
( pretty-print-json-tab-width)→exact-positive-integer?
width:exact-positive-integer?= 8
procedure
( jsexpr->pretty-json js)→string?
js:jsexpr?
procedure
js:jsexpr?
procedure
( format-json json)→string?
json:string?
procedure
( format-json/bytes json)→bytes?
json:bytes?
procedure
( pretty-print-jsexpr js[out])→void?
js:jsexpr?
procedure
( pretty-print-json json[out])→void?
json:string?
procedure
( pretty-print-json/bytes json[out])→void?
json:bytes?
Uses an external jq process to format JSON. Also allows you to run arbitrary jsexprs through JQ.
parameter
( jq-path )→(or/cpath-string? #f)
procedure
( jsexpr-transform jsfilter)→jsexpr?
js:jsexpr?filter:string?
Technically not formatting, but it uses the same framework, so why not include it?
procedure
( jsexpr->pretty-json js)→string?
js:jsexpr?
procedure
js:jsexpr?
procedure
( format-json json)→string?
json:string?
procedure
( format-json/bytes json)→bytes?
json:bytes?
procedure
( pretty-print-jsexpr js[out])→void?
js:jsexpr?
procedure
( pretty-print-json json[out])→void?
json:string?
procedure
( pretty-print-json/bytes json[out])→void?
json:bytes?
All of the above formatter modules use these parameters unless otherwise noted.
= 2
parameter
( pretty-print-json-colorize)→(or/cboolean? 'terminal)
= 'terminal
Colors are customized as in the same manner as jq.