From 8d1cb7b3ef96a1b7c6911c34c020e0f3a76dd7f1 Mon Sep 17 00:00:00 2001 From: Rnhmjoj Date: Tue, 25 Nov 2014 00:08:56 +0100 Subject: [PATCH] Add print function --- Json.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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