@@ -3,6 +3,8 @@
3module Json.Encode
3module Json.Encode
@@ -106,6 +108,52 @@ write path value =
106 B.hPutBuilder handle (encode value)
108 B.hPutBuilder handle (encode value)
111+writeUgly :: FilePath -> Value -> IO ()
112+writeUgly path value =
113+ withBinaryFile path WriteMode $ \handle ->
114+ B.hPutBuilder handle (encodeUgly value)
121+encodeUgly :: Value -> B.Builder
127+ Array (first : rest) ->
130+ B.char7 ',' <> encodeUgly entry
132+ B.char7 '[' <> encodeUgly first <> mconcat (map encodeEntry rest) <> B.char7 ']'
137+ Object (first : rest) ->
139+ encodeEntry char (key, entry) =
140+ B.char7 char <> encodeString key <> B.char7 ':' <> encodeUgly entry
142+ encodeEntry '[' first <> mconcat (map (encodeEntry ',') rest) <> B.char7 ']'
148+ B.string7 (if boolean then "true" else "false")