From 91d6f8c841c6a0358934029c39192241fe4a2fad Mon Sep 17 00:00:00 2001 From: "S. Zeid" Date: Wed, 11 Oct 2023 22:37:50 -0500 Subject: [PATCH] imp: lib: include adeclarationinfo, if present, in accounts JSON Note that this does not add the declaration info if it is not already present. --- hledger-lib/Hledger/Data/Json.hs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hledger-lib/Hledger/Data/Json.hs b/hledger-lib/Hledger/Data/Json.hs index a3ac1f506..b3aeb82d2 100644 --- a/hledger-lib/Hledger/Data/Json.hs +++ b/hledger-lib/Hledger/Data/Json.hs @@ -165,20 +165,21 @@ accountKV :: #endif => Account -> [kv] accountKV a = - [ "aname" .= aname a - , "aebalance" .= aebalance a - , "aibalance" .= aibalance a - , "anumpostings" .= anumpostings a - , "aboring" .= aboring a + [ "aname" .= aname a + , "adeclarationinfo" .= adeclarationinfo a + , "aebalance" .= aebalance a + , "aibalance" .= aibalance a + , "anumpostings" .= anumpostings a + , "aboring" .= aboring a -- To avoid a cycle, show just the parent account's name -- in a dummy field. When re-parsed, there will be no parent. - , "aparent_" .= maybe "" aname (aparent a) + , "aparent_" .= maybe "" aname (aparent a) -- Just the names of subaccounts, as a dummy field, ignored when parsed. - , "asubs_" .= map aname (asubs a) + , "asubs_" .= map aname (asubs a) -- The actual subaccounts (and their subs..), making a (probably highly redundant) tree -- ,"asubs" .= asubs a -- Omit the actual subaccounts - , "asubs" .= ([]::[Account]) + , "asubs" .= ([]::[Account]) ] instance ToJSON Ledger