diff --git a/src/Json.hs b/src/Json.hs index fab4612..0083867 100644 --- a/src/Json.hs +++ b/src/Json.hs @@ -24,12 +24,13 @@ repr obj = repr' obj 0 where repr' val lev = case val of Array x -> intercalate ", " $ mapl (\i -> repr' i lev) x - Object x -> drop 1 $ concat $ map (dump x lev) $ H.keys x + Object x -> newline lev $ concat $ map (dump x lev) $ H.keys x String x -> unpack x Number x -> show x Bool x -> show x Null -> "null" - mapl f v = V.toList $ V.map f v + mapl f v = V.toList (V.map f v) + newline n = if n == 1 then id else drop 1 indent l = '\n' : (concat . replicate l) " " dump o l k = concat [indent l, unpack k, ": ", repr' (o |. k) (l+1)]