[Switch to json-0.3.3 module. prb@mult.ifario.us**20080616194416] { merger 0.0 ( hunk ./perpubplat.cabal 2 -version: 0.9.1 +version: 0.10.0 hunk ./perpubplat.cabal 2 -version: 0.9.1 +version: 0.10.0 ) hunk ./perpubplat.cabal 18 - old-locale >= 1.0, json == 0.1, network >= 2.1, time >= 1.1.2.0, unix >= 2.3, - fastcgi >= 3001.0.0, bytestring >= 0.9, pureMD5 >= 0.1.1, base64-string, - hxt == 7.5, hslogger >= 1.0.5 + old-locale >= 1.0, json >= 0.3.3, network >= 2.1, time >= 1.1.2.0, + unix >= 2.3, fastcgi >= 3001.0.0, bytestring >= 0.9, pureMD5 >= 0.1.1, + base64-string, hxt == 7.5, hslogger >= 1.0.5 hunk ./src/Blog/Constants.hs 90 -flickr_user = "92922008@N00" +flickr_user = "92922008@N00" -- fill yours in merger 0.0 ( hunk ./src/Blog/Constants.hs 93 -flickr_api_key = "233b3c334c93b6f999f9b4b810f9d603" +flickr_api_key = "" -- fill yours in hunk ./src/Blog/Constants.hs 93 -flickr_api_key = "233b3c334c93b6f999f9b4b810f9d603" +flickr_api_key = "233b3c334c93b6f999f9b4b810f9d603" -- fill yours in ) hunk ./src/Blog/Constants.hs 96 -delicious_user = "prb" +delicious_user = "prb" -- fill yours in hunk ./src/Blog/Widgets/Delicious.hs 11 -import qualified Text.Json as J +import Text.JSON hunk ./src/Blog/Widgets/Delicious.hs 250 - Right (J.Array a) -> + Right (JSArray a) -> hunk ./src/Blog/Widgets/Delicious.hs 259 -unpack_json :: [J.Value] -> DeliciousRecord +unpack_json :: [JSValue] -> DeliciousRecord hunk ./src/Blog/Widgets/Delicious.hs 261 -unpack_json [o] = DeliciousRecord { hash = uns $ M.findWithDefault blank "hash" $ uno o - , top_tags = to_tag_list . uno $ M.findWithDefault empty_object "top_tags" $ uno o - , url = uns $ M.findWithDefault blank "url" $ uno o - , total_posts = unn $ M.findWithDefault zero "total_posts" $ uno o } +unpack_json [o] = DeliciousRecord { hash = unsWithDefault "" $ o "hash" + , top_tags = to_tag_list $ o "top_tags" + , url = unsWithDefault "" $ o "url" + , total_posts = unnWithDefault 0 $ o "total_posts" } hunk ./src/Blog/Widgets/Delicious.hs 266 -to_tag_list :: M.Map String J.Value -> [(String,Int)] -to_tag_list m = map (\(s,n) -> (s, unn n)) $ M.toList m +to_tag_list :: JSValue -> [(String,Int)] +to_tag_list (JSArray [JSObject o]) = (map (\(s,n) -> (s, unn n))) $ fromJSObject o +to_tag_list _ = [] hunk ./src/Blog/Widgets/FlickrCollage.hs 14 -import qualified Text.Json as J +import Text.JSON hunk ./src/Blog/Widgets/FlickrCollage.hs 114 -to_photo :: J.Value -> FlickrPhoto +to_photo :: JSValue -> FlickrPhoto hunk ./src/Blog/Widgets/JsonUtilities.hs 3 -import qualified Text.Json as J -import qualified Data.Map as M -import qualified Text.ParserCombinators.Parsec as P +import Text.JSON hunk ./src/Blog/Widgets/JsonUtilities.hs 6 -parse_utf8_json :: String -> Either String J.Value -parse_utf8_json s = case ( P.parse J.json "" ) . UTF8.decodeString $ s of - Right v -> Right v - Left err -> Left $ show err +parse_utf8_json :: String -> Either String JSValue +parse_utf8_json = resultToEither . decode . UTF8.decodeString hunk ./src/Blog/Widgets/JsonUtilities.hs 9 -() :: J.Value -> String -> J.Value -(J.Object o) s = o M.! s -(J.Array a) s = J.Array $ map (flip () $ s) a +() :: JSValue -> String -> JSValue +(JSObject o) s = flatten . JSArray $ map snd $ filter (((==) s) . fst) $ fromJSObject o +(JSArray a) s = flatten . JSArray $ map (flip () $ s) a +_ _ = JSNull hunk ./src/Blog/Widgets/JsonUtilities.hs 14 -blank :: J.Value -blank = J.String "" +flatten :: JSValue -> JSValue +flatten (JSObject o) = JSObject $ toJSObject $ map (\(s,v) -> (s,flatten v)) $ fromJSObject o +flatten (JSArray [x]) = flatten x +flatten (JSArray a) = JSArray $ map flatten a +flatten y = y hunk ./src/Blog/Widgets/JsonUtilities.hs 20 -zero :: J.Value -zero = J.Number 0 +blank :: JSValue +blank = JSString $ toJSString "" hunk ./src/Blog/Widgets/JsonUtilities.hs 23 -empty_object :: J.Value -empty_object = J.Object M.empty +zero :: JSValue +zero = JSRational 0 hunk ./src/Blog/Widgets/JsonUtilities.hs 26 -empty_array :: J.Value -empty_array = J.Array [] +empty_object :: JSValue +empty_object = JSObject $ toJSObject [] hunk ./src/Blog/Widgets/JsonUtilities.hs 29 -unn :: J.Value -> Int -unn (J.Number n) = fromInteger . round $ n +empty_array :: JSValue +empty_array = JSArray [] hunk ./src/Blog/Widgets/JsonUtilities.hs 32 -uno :: J.Value -> M.Map String J.Value -uno (J.Object o) = o +unn_ :: JSValue -> [Int] +unn_ a@(JSArray _) = map unn $ una . flatten $ a hunk ./src/Blog/Widgets/JsonUtilities.hs 35 -una :: J.Value -> [J.Value] -una (J.Array a) = a +unnWithDefault :: Int -> JSValue -> Int +unnWithDefault i JSNull = i +unnWithDefault i (JSArray []) = i +unnWithDefault i (JSArray [j]) = unnWithDefault i j +unnWithDefault _ j = unn j hunk ./src/Blog/Widgets/JsonUtilities.hs 41 -uns :: J.Value -> String -uns (J.String s) = s +unn :: JSValue -> Int +unn (JSRational n) = fromInteger . round $ n +unn (JSArray [n@(JSRational _)]) = unn n hunk ./src/Blog/Widgets/JsonUtilities.hs 45 +uno :: JSValue -> [(String,JSValue)] +uno (JSObject o) = fromJSObject o +uno _ = error "Can't un-object a non-JSOBject value." + +una :: JSValue -> [JSValue] +una (JSArray a) = a +una _ = error "Can't un-array a non-JSArray value." + +uns_ :: JSValue -> [String] +uns_ a@(JSArray _) = map uns $ una . flatten $ a + +uns :: JSValue -> String +uns (JSString s) = fromJSString s +uns (JSArray [s@(JSString _)]) = uns s +uns _ = error "Can't un-string non-JSString value." + +unsWithDefault :: String -> JSValue -> String +unsWithDefault s JSNull = s +unsWithDefault s (JSArray []) = s +unsWithDefault s (JSArray [v]) = unsWithDefault s v +unsWithDefault _ v = uns v hunk ./src/Blog/Widgets/StreamOfConsciousness/Twitter.hs 18 -import qualified Text.Json as J +import Text.JSON hunk ./src/Blog/Widgets/StreamOfConsciousness/Twitter.hs 66 - Right v@(J.Array _) -> + Right v@(JSArray _) -> hunk ./src/Blog/Widgets/StreamOfConsciousness/Twitter.hs 74 -tweets_to_thoughts :: String -> J.Value -> [T.Thought] +tweets_to_thoughts :: String -> JSValue -> [T.Thought] hunk ./src/Blog/Widgets/StreamOfConsciousness/Twitter.hs 84 - Right v@(J.Array _) -> + Right v@(JSArray _) -> hunk ./src/Blog/Widgets/StreamOfConsciousness/Twitter.hs 92 -replies_to_thoughts :: String -> J.Value -> [T.Thought] +replies_to_thoughts :: String -> JSValue -> [T.Thought] hunk ./src/Blog/Widgets/StreamOfConsciousness/Twitter.hs 96 - users = map uns $ una $ v "user" "screen_name" + users = uns_ $ v "user" "screen_name" hunk ./src/Blog/Widgets/StreamOfConsciousness/Twitter.hs 98 - pre_texts = map uns $ una $ v "text" + pre_texts = uns_ $ v "text" hunk ./src/Blog/Widgets/StreamOfConsciousness/Twitter.hs 100 - times = map (convert_twitter_tstmp . uns) $ una $ v "created_at" + times = map convert_twitter_tstmp $ uns_ $ v "created_at" hunk ./src/Blog/Widgets/StreamOfConsciousness/TwitterNanny.hs 13 -import qualified Text.Json as J +import Text.JSON hunk ./src/Blog/Widgets/StreamOfConsciousness/TwitterNanny.hs 40 - Right v@(J.Object _) -> + Right v@(JSObject _) -> hunk ./src/Blog/Widgets/StreamOfConsciousness/TwitterNanny.hs 43 - L.errorM log_handle $ "Unexpected non-array JSON response that starts with: " + L.errorM log_handle $ "Unexpected non-object JSON response that starts with: " hunk ./src/Blog/Widgets/StreamOfConsciousness/TwitterNanny.hs 48 -compute_new_delays :: [(Worker,Int)] -> J.Value -> IO () +compute_new_delays :: [(Worker,Int)] -> JSValue -> IO () }