Ancient Haskell version of jq. Might be useful someday. Maybe.

This commit is contained in:
Stephen Dolan committed 2012-09-18 17:29:56 +01:00
1 parent eca89acee0
commit 3622810ea7
7 files changed
+269 -46

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
module PrettyJSON where
import Text.JSON
import Text.PrettyPrint
renderJSON (JSArray vals) = brackets $ fsep $ punctuate comma $ map renderJSON vals
renderJSON (JSObject jsObject) =
let object = fromJSObject jsObject
in braces $ fsep $ punctuate comma $
[hang (renderJSON (JSString $ toJSString $ k) <> colon) 2 (renderJSON v)
| (k,v) <- object]
renderJSON x = text $ encode x