fix indentation of nested objects
This commit is contained in:
parent
2b0551ca07
commit
7305b4f3c9
@ -9,19 +9,19 @@ import Data.List (intercalate)
|
|||||||
import qualified Data.Vector as V
|
import qualified Data.Vector as V
|
||||||
import qualified Data.HashMap.Strict as H
|
import qualified Data.HashMap.Strict as H
|
||||||
|
|
||||||
-- | Get the JSON value of a key
|
-- | Gets the JSON value of a key
|
||||||
(|.) :: Object -> Text -> Value
|
(|.) :: Object -> Text -> Value
|
||||||
obj |. key = case parse (.: key) obj of
|
obj |. key = case parse (.: key) obj of
|
||||||
Success val -> val
|
Success val -> val
|
||||||
Error err -> toJSON err
|
Error err -> toJSON err
|
||||||
|
|
||||||
|
|
||||||
-- | Get the 'String' value of a key
|
-- | Gets the 'String' value of a key
|
||||||
(|:) :: Object -> Text -> String
|
(|:) :: Object -> Text -> String
|
||||||
obj |: key = repr (obj |. key)
|
obj |: key = repr (obj |. key)
|
||||||
|
|
||||||
|
|
||||||
-- | Create a String representation of a 'Value'
|
-- | Creates a 'String' representation of a 'Value'
|
||||||
repr :: Value -> String
|
repr :: Value -> String
|
||||||
repr obj = repr' obj 0 where
|
repr obj = repr' obj 0 where
|
||||||
repr' val lev =
|
repr' val lev =
|
||||||
@ -33,7 +33,7 @@ repr obj = repr' obj 0 where
|
|||||||
Bool x -> show x
|
Bool x -> show x
|
||||||
Null -> "null"
|
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
|
newline n = if n /= 0 then id else drop 1
|
||||||
indent l = '\n' : (concat . replicate l) " "
|
indent l = '\n' : (concat . replicate l) " "
|
||||||
dump o l k = concat [indent l, unpack k, ": ", repr' (o |. k) (l+1)]
|
dump o l k = concat [indent l, unpack k, ": ", repr' (o |. k) (l+1)]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user