Skip to content

Commit c5537ce

Browse files
committed
;lib: drop more unnecessary toJSON calls
1 parent 7e49d8c commit c5537ce

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

hledger-lib/Hledger/Data/Json.hs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,20 @@ instance ToJSON PostingType
5959

6060
instance ToJSON Posting where
6161
toJSON Posting{..} = object
62-
["pdate" .= toJSON pdate
63-
,"pdate2" .= toJSON pdate2
64-
,"pstatus" .= toJSON pstatus
65-
,"paccount" .= toJSON paccount
66-
,"pamount" .= toJSON pamount
67-
,"pcomment" .= toJSON pcomment
68-
,"ptype" .= toJSON ptype
69-
,"ptags" .= toJSON ptags
70-
,"pbalanceassertion" .= toJSON pbalanceassertion
62+
["pdate" .= pdate
63+
,"pdate2" .= pdate2
64+
,"pstatus" .= pstatus
65+
,"paccount" .= paccount
66+
,"pamount" .= pamount
67+
,"pcomment" .= pcomment
68+
,"ptype" .= ptype
69+
,"ptags" .= ptags
70+
,"pbalanceassertion" .= pbalanceassertion
7171
-- To avoid a cycle, show just the parent transaction's index number
7272
-- in a dummy field. When re-parsed, there will be no parent.
73-
,"ptransaction_" .= toJSON (maybe "" (show.tindex) ptransaction)
73+
,"ptransaction_" .= maybe "" (show.tindex) ptransaction
7474
-- This is probably not wanted in json, we discard it.
75-
,"poriginal" .= toJSON (Nothing :: Maybe Posting)
75+
,"poriginal" .= (Nothing :: Maybe Posting)
7676
]
7777

7878
instance ToJSON Transaction
@@ -93,20 +93,20 @@ instance ToJSON Journal
9393

9494
instance ToJSON Account where
9595
toJSON a = object
96-
["aname" .= toJSON (aname a)
97-
,"aebalance" .= toJSON (aebalance a)
98-
,"aibalance" .= toJSON (aibalance a)
99-
,"anumpostings" .= toJSON (anumpostings a)
100-
,"aboring" .= toJSON (aboring a)
96+
["aname" .= aname a
97+
,"aebalance" .= aebalance a
98+
,"aibalance" .= aibalance a
99+
,"anumpostings" .= anumpostings a
100+
,"aboring" .= aboring a
101101
-- To avoid a cycle, show just the parent account's name
102102
-- in a dummy field. When re-parsed, there will be no parent.
103-
,"aparent_" .= toJSON (maybe "" aname $ aparent a)
103+
,"aparent_" .= maybe "" aname (aparent a)
104104
-- Just the names of subaccounts, as a dummy field, ignored when parsed.
105-
,"asubs_" .= toJSON (map aname $ asubs a)
105+
,"asubs_" .= map aname (asubs a)
106106
-- The actual subaccounts (and their subs..), making a (probably highly redundant) tree
107-
-- ,"asubs" .= toJSON (asubs a)
107+
-- ,"asubs" .= asubs a
108108
-- Omit the actual subaccounts
109-
,"asubs" .= toJSON ([]::[Account])
109+
,"asubs" .= ([]::[Account])
110110
]
111111

112112
deriving instance Generic (Ledger)
@@ -184,4 +184,4 @@ readJsonFile f = do
184184
-- Example:
185185
-- >>> writeJsonFile "out.json" nullmixedamt
186186
writeJsonFile :: ToJSON a => FilePath -> a -> IO ()
187-
writeJsonFile f v = BL.writeFile f (encode $ toJSON v)
187+
writeJsonFile f v = BL.writeFile f (encode v)

0 commit comments

Comments
 (0)