diff --git a/src/Json.hs b/src/Json.hs index d35ef1c..f2ffa8f 100644 --- a/src/Json.hs +++ b/src/Json.hs @@ -9,19 +9,19 @@ import Data.List (intercalate) import qualified Data.Vector as V import qualified Data.HashMap.Strict as H --- | Get the JSON value of a key +-- | Gets the JSON value of a key (|.) :: Object -> Text -> Value obj |. key = case parse (.: key) obj of Success val -> val Error err -> toJSON err --- | Get the 'String' value of a key +-- | Gets the 'String' value of a key (|:) :: Object -> Text -> String obj |: key = repr (obj |. key) --- | Create a String representation of a 'Value' +-- | Creates a 'String' representation of a 'Value' repr :: Value -> String repr obj = repr' obj 0 where repr' val lev = @@ -33,7 +33,7 @@ repr obj = repr' obj 0 where Bool x -> show x Null -> "null" 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) " " dump o l k = concat [indent l, unpack k, ": ", repr' (o |. k) (l+1)]