summaryrefslogtreecommitdiff
path: root/src/Data/Torrent
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-03-20 03:19:14 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-03-20 03:19:14 +0400
commit95f519df298c98d966c6408cac33cdd57b8e8a03 (patch)
treee6b0fb3ba6dafd6771cfc5084fcb3f7b1a7e26da /src/Data/Torrent
parent17949276fbd32ab75bcb18016210b6947df54ed1 (diff)
Add instance ToJSON TrackerEntry
Diffstat (limited to 'src/Data/Torrent')
-rw-r--r--src/Data/Torrent/JSON.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Data/Torrent/JSON.hs b/src/Data/Torrent/JSON.hs
index 6a0aa510..71db3039 100644
--- a/src/Data/Torrent/JSON.hs
+++ b/src/Data/Torrent/JSON.hs
@@ -1,3 +1,4 @@
1{-# OPTIONS_GHC -fno-warn-orphans #-}
1module Data.Torrent.JSON 2module Data.Torrent.JSON
2 ( omitLensPrefix 3 ( omitLensPrefix
3 , omitRecordPrefix 4 , omitRecordPrefix
@@ -9,6 +10,7 @@ import Data.Aeson.Types
9import Data.ByteString as BS 10import Data.ByteString as BS
10import Data.ByteString.Base16 as Base16 11import Data.ByteString.Base16 as Base16
11import Data.Char 12import Data.Char
13import Data.IP
12import Data.List as L 14import Data.List as L
13import Data.Text.Encoding as T 15import Data.Text.Encoding as T
14 16
@@ -44,3 +46,11 @@ instance FromJSON ByteString where
44 if BS.null bad 46 if BS.null bad
45 then return ok 47 then return ok
46 else fail "parseJSON: unable to decode ByteString" 48 else fail "parseJSON: unable to decode ByteString"
49
50instance ToJSON IP where
51 toJSON = toJSON . show
52
53instance FromJSON IP where
54 parseJSON v = do
55 str <- parseJSON v
56 return $ read str