@@ -59,20 +59,20 @@ instance ToJSON PostingType
59
59
60
60
instance ToJSON Posting where
61
61
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
71
71
-- To avoid a cycle, show just the parent transaction's index number
72
72
-- 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
74
74
-- This is probably not wanted in json, we discard it.
75
- ," poriginal" .= toJSON (Nothing :: Maybe Posting )
75
+ ," poriginal" .= (Nothing :: Maybe Posting )
76
76
]
77
77
78
78
instance ToJSON Transaction
@@ -93,20 +93,20 @@ instance ToJSON Journal
93
93
94
94
instance ToJSON Account where
95
95
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
101
101
-- To avoid a cycle, show just the parent account's name
102
102
-- 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)
104
104
-- 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)
106
106
-- The actual subaccounts (and their subs..), making a (probably highly redundant) tree
107
- -- ,"asubs" .= toJSON ( asubs a)
107
+ -- ,"asubs" .= asubs a
108
108
-- Omit the actual subaccounts
109
- ," asubs" .= toJSON ([] :: [Account ])
109
+ ," asubs" .= ([] :: [Account ])
110
110
]
111
111
112
112
deriving instance Generic (Ledger )
@@ -184,4 +184,4 @@ readJsonFile f = do
184
184
-- Example:
185
185
-- >>> writeJsonFile "out.json" nullmixedamt
186
186
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