diff --git a/Json.hs b/Json.hs index b1248cd..5d908e7 100644 --- a/Json.hs +++ b/Json.hs @@ -1,4 +1,9 @@ -module Json where +module Json +( (|.) +, (|:) +, repr +, jprint +) where import Data.Aeson import Data.Aeson.Types (parse) @@ -15,6 +20,7 @@ obj |. key = case parse (.: key) obj of Error err -> toJSON err -- Get the String value of a key + (|:) :: Object -> Text -> String obj |: key = repr' (obj |. key) 0 @@ -36,3 +42,7 @@ repr' val lev = indent = '\n' : (concat . replicate lev) " " dump o k = concat [indent, unpack k, ": ", repr' (o |. k) (lev+1)] mapl f v = V.toList $ V.map f v + +-- Print a representation of a JSON Value +jprint :: Value -> IO () +jprint = putStrLn . repr \ No newline at end of file