Remove extra newline in repr
This commit is contained in:
parent
482f28717b
commit
1bb362651c
14
Json.hs
14
Json.hs
@ -16,13 +16,17 @@ obj |. key = case parse (.: key) obj of
|
||||
|
||||
-- Get the String value of a key
|
||||
(|:) :: Object -> Text -> String
|
||||
obj |: key = repr (obj |. key) 0
|
||||
obj |: key = repr' (obj |. key) 0
|
||||
|
||||
-- Create a String representation of a JSON
|
||||
repr :: Value -> String
|
||||
repr obj = drop 1 $ repr' obj 0
|
||||
|
||||
-- Create a String representation of a JSON Value
|
||||
repr :: Value -> Int -> String
|
||||
repr val lev =
|
||||
repr' :: Value -> Int -> String
|
||||
repr' val lev =
|
||||
case val of
|
||||
Array x -> intercalate ", " $ mapl (\i -> repr i lev) x
|
||||
Array x -> intercalate ", " $ mapl (\i -> repr' i lev) x
|
||||
Object x -> concat $ map (dump x) $ H.keys x
|
||||
String x -> unpack x
|
||||
Number x -> show x
|
||||
@ -30,5 +34,5 @@ repr val lev =
|
||||
Null -> "null"
|
||||
where
|
||||
indent = '\n' : (concat . replicate lev) " "
|
||||
dump o k = concat [indent, unpack k, ": ", repr (o |. k) (lev+1)]
|
||||
dump o k = concat [indent, unpack k, ": ", repr' (o |. k) (lev+1)]
|
||||
mapl f v = V.toList $ V.map f v
|
||||
|
Loading…
Reference in New Issue
Block a user