1{-# OPTIONS_GHC -fno-warn-orphans #-}
3import Blaze.ByteString.Builder (toLazyByteString)
4import Blaze.ByteString.Builder.Char.Utf8 (fromString)
5import Control.DeepSeq (NFData(rnf))
7import qualified Data.Aeson as A
8import qualified Data.ByteString.Lazy as BL
9import qualified Data.ByteString.Lazy.Internal as BL
10import qualified Text.JSON as J
12instance (NFData v) => NFData (J.JSObject v) where
13 rnf o = rnf (J.fromJSObject o)
15instance NFData J.JSValue where
17 rnf (J.JSBool b) = rnf b
18 rnf (J.JSRational a b) = rnf a `seq` rnf b `seq` ()
19 rnf (J.JSString s) = rnf (J.fromJSString s)
20 rnf (J.JSArray lst) = rnf lst
21 rnf (J.JSObject o) = rnf o
23instance NFData BL.ByteString where
24 rnf (BL.Chunk _ bs) = rnf bs
27decodeJ :: String -> J.JSValue
29 case J.decodeStrict s of
31 J.Error _ -> error "fail to parse via JSON"
33decodeA :: BL.ByteString -> A.Value
34decodeA s = case A.decode s of
36 Nothing -> error "fail to parse via Aeson"
38encodeJ :: J.JSValue -> BL.ByteString
39encodeJ = toLazyByteString . fromString . J.encode
43 let enFile = "json-data/twitter100.json"
44 jpFile = "json-data/jp100.json"
45 enA <- BL.readFile enFile
46 enJ <- readFile enFile
47 jpA <- BL.readFile jpFile
48 jpJ <- readFile jpFile
52 bench "aeson" $ nf decodeA enA
53 , bench "json" $ nf decodeJ enJ
56 bench "aeson" $ nf decodeA jpA
57 , bench "json" $ nf decodeJ jpJ
62 bench "aeson" $ nf A.encode (decodeA enA)
63 , bench "json" $ nf encodeJ (decodeJ enJ)
66 bench "aeson" $ nf A.encode (decodeA jpA)
67 , bench "json" $ nf encodeJ (decodeJ jpJ)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list