hledger-lib-1.52.1: A library providing the core functionality of hledger

Safe Haskell | None
Language | GHC2021

Hledger.Data.Json

Contents

- Instances
- Utilities
- Orphan instances

Synopsis

- toJsonText :: ToJSON a => a -> Text
- writeJsonFile :: ToJSON a => FilePath -> a -> IO ()
- readJsonFile :: FromJSON a => FilePath -> IO a

# Instances

# Utilities

toJsonText :: ToJSON a => a -> Text Source #

Show a JSON-convertible haskell value as pretty-printed JSON text.

writeJsonFile :: ToJSON a => FilePath -> a -> IO () Source #

Write a JSON-convertible haskell value to a pretty-printed JSON file. Eg: writeJsonFile "a.json" nulltransaction

readJsonFile :: FromJSON a => FilePath -> IO a Source #

Read a JSON file and decode it to the target type, or raise an error if we can't. Eg: readJsonFile "a.json" :: IO Transaction

# Orphan instances

FromJSON AccountDeclarationInfo Source # |
Instance details Methods parseJSON :: Value -> Parser AccountDeclarationInfo Source # parseJSONList :: Value -> Parser [AccountDeclarationInfo] Source # omittedField :: Maybe AccountDeclarationInfo Source #
FromJSON Amount Source # |
Instance details Methods parseJSON :: Value -> Parser Amount Source # parseJSONList :: Value -> Parser [Amount] Source # omittedField :: Maybe Amount Source #
FromJSON AmountCost Source # |
Instance details Methods parseJSON :: Value -> Parser AmountCost Source # parseJSONList :: Value -> Parser [AmountCost] Source # omittedField :: Maybe AmountCost Source #
FromJSON AmountPrecision Source # |
Instance details Methods parseJSON :: Value -> Parser AmountPrecision Source # parseJSONList :: Value -> Parser [AmountPrecision] Source # omittedField :: Maybe AmountPrecision Source #
FromJSON AmountStyle Source # |
Instance details Methods parseJSON :: Value -> Parser AmountStyle Source # parseJSONList :: Value -> Parser [AmountStyle] Source # omittedField :: Maybe AmountStyle Source #
FromJSON BalanceAssertion Source # |
Instance details Methods parseJSON :: Value -> Parser BalanceAssertion Source # parseJSONList :: Value -> Parser [BalanceAssertion] Source # omittedField :: Maybe BalanceAssertion Source #
FromJSON BalanceData Source # |
Instance details Methods parseJSON :: Value -> Parser BalanceData Source # parseJSONList :: Value -> Parser [BalanceData] Source # omittedField :: Maybe BalanceData Source #
FromJSON CostBasis Source # |
Instance details Methods parseJSON :: Value -> Parser CostBasis Source # parseJSONList :: Value -> Parser [CostBasis] Source # omittedField :: Maybe CostBasis Source #
FromJSON DigitGroupStyle Source # |
Instance details Methods parseJSON :: Value -> Parser DigitGroupStyle Source # parseJSONList :: Value -> Parser [DigitGroupStyle] Source # omittedField :: Maybe DigitGroupStyle Source #
FromJSON MarketPrice Source # |
Instance details Methods parseJSON :: Value -> Parser MarketPrice Source # parseJSONList :: Value -> Parser [MarketPrice] Source # omittedField :: Maybe MarketPrice Source #
FromJSON MixedAmount Source # |
Instance details Methods parseJSON :: Value -> Parser MixedAmount Source # parseJSONList :: Value -> Parser [MixedAmount] Source # omittedField :: Maybe MixedAmount Source #
FromJSON Posting Source # |
Instance details Methods parseJSON :: Value -> Parser Posting Source # parseJSONList :: Value -> Parser [Posting] Source # omittedField :: Maybe Posting Source #
FromJSON PostingType Source # |
Instance details Methods parseJSON :: Value -> Parser PostingType Source # parseJSONList :: Value -> Parser [PostingType] Source # omittedField :: Maybe PostingType Source #
FromJSON Rounding Source # |
Instance details Methods parseJSON :: Value -> Parser Rounding Source # parseJSONList :: Value -> Parser [Rounding] Source # omittedField :: Maybe Rounding Source #
FromJSON Side Source # |
Instance details Methods parseJSON :: Value -> Parser Side Source # parseJSONList :: Value -> Parser [Side] Source # omittedField :: Maybe Side Source #
FromJSON Status Source # |
Instance details Methods parseJSON :: Value -> Parser Status Source # parseJSONList :: Value -> Parser [Status] Source # omittedField :: Maybe Status Source #
FromJSON Transaction Source # |
Instance details Methods parseJSON :: Value -> Parser Transaction Source # parseJSONList :: Value -> Parser [Transaction] Source # omittedField :: Maybe Transaction Source #
FromJSON Pos Source # |
Instance details Methods parseJSON :: Value -> Parser Pos Source # parseJSONList :: Value -> Parser [Pos] Source # omittedField :: Maybe Pos Source #
FromJSON SourcePos Source # |
Instance details Methods parseJSON :: Value -> Parser SourcePos Source # parseJSONList :: Value -> Parser [SourcePos] Source # omittedField :: Maybe SourcePos Source #
ToJSON AccountAlias Source # |
Instance details Methods toJSON :: AccountAlias -> Value Source # toEncoding :: AccountAlias -> Encoding Source # toJSONList :: [AccountAlias] -> Value Source # toEncodingList :: [AccountAlias] -> Encoding Source # omitField :: AccountAlias -> Bool Source #
ToJSON AccountDeclarationInfo Source # |
Instance details Methods toJSON :: AccountDeclarationInfo -> Value Source # toEncoding :: AccountDeclarationInfo -> Encoding Source # toJSONList :: [AccountDeclarationInfo] -> Value Source # toEncodingList :: [AccountDeclarationInfo] -> Encoding Source # omitField :: AccountDeclarationInfo -> Bool Source #
ToJSON AccountType Source # |
Instance details Methods toJSON :: AccountType -> Value Source # toEncoding :: AccountType -> Encoding Source # toJSONList :: [AccountType] -> Value Source # toEncodingList :: [AccountType] -> Encoding Source # omitField :: AccountType -> Bool Source #
ToJSON Amount Source # |
Instance details Methods toJSON :: Amount -> Value Source # toEncoding :: Amount -> Encoding Source # toJSONList :: [Amount] -> Value Source # toEncodingList :: [Amount] -> Encoding Source # omitField :: Amount -> Bool Source #
ToJSON AmountCost Source # |
Instance details Methods toJSON :: AmountCost -> Value Source # toEncoding :: AmountCost -> Encoding Source # toJSONList :: [AmountCost] -> Value Source # toEncodingList :: [AmountCost] -> Encoding Source # omitField :: AmountCost -> Bool Source #
ToJSON AmountPrecision Source # |
Instance details Methods toJSON :: AmountPrecision -> Value Source # toEncoding :: AmountPrecision -> Encoding Source # toJSONList :: [AmountPrecision] -> Value Source # toEncodingList :: [AmountPrecision] -> Encoding Source # omitField :: AmountPrecision -> Bool Source #
ToJSON AmountStyle Source # |
Instance details Methods toJSON :: AmountStyle -> Value Source # toEncoding :: AmountStyle -> Encoding Source # toJSONList :: [AmountStyle] -> Value Source # toEncodingList :: [AmountStyle] -> Encoding Source # omitField :: AmountStyle -> Bool Source #
ToJSON BalanceAssertion Source # |
Instance details Methods toJSON :: BalanceAssertion -> Value Source # toEncoding :: BalanceAssertion -> Encoding Source # toJSONList :: [BalanceAssertion] -> Value Source # toEncodingList :: [BalanceAssertion] -> Encoding Source # omitField :: BalanceAssertion -> Bool Source #
ToJSON BalanceData Source # |
Instance details Methods toJSON :: BalanceData -> Value Source # toEncoding :: BalanceData -> Encoding Source # toJSONList :: [BalanceData] -> Value Source # toEncodingList :: [BalanceData] -> Encoding Source # omitField :: BalanceData -> Bool Source #
ToJSON Commodity Source # |
Instance details Methods toJSON :: Commodity -> Value Source # toEncoding :: Commodity -> Encoding Source # toJSONList :: [Commodity] -> Value Source # toEncodingList :: [Commodity] -> Encoding Source # omitField :: Commodity -> Bool Source #
ToJSON CostBasis Source # |
Instance details Methods toJSON :: CostBasis -> Value Source # toEncoding :: CostBasis -> Encoding Source # toJSONList :: [CostBasis] -> Value Source # toEncodingList :: [CostBasis] -> Encoding Source # omitField :: CostBasis -> Bool Source #
ToJSON DateSpan Source # |
Instance details Methods toJSON :: DateSpan -> Value Source # toEncoding :: DateSpan -> Encoding Source # toJSONList :: [DateSpan] -> Value Source # toEncodingList :: [DateSpan] -> Encoding Source # omitField :: DateSpan -> Bool Source #
ToJSON DigitGroupStyle Source # |
Instance details Methods toJSON :: DigitGroupStyle -> Value Source # toEncoding :: DigitGroupStyle -> Encoding Source # toJSONList :: [DigitGroupStyle] -> Value Source # toEncodingList :: [DigitGroupStyle] -> Encoding Source # omitField :: DigitGroupStyle -> Bool Source #
ToJSON EFDay Source # |
Instance details Methods toJSON :: EFDay -> Value Source # toEncoding :: EFDay -> Encoding Source # toJSONList :: [EFDay] -> Value Source # toEncodingList :: [EFDay] -> Encoding Source # omitField :: EFDay -> Bool Source #
ToJSON Interval Source # |
Instance details Methods toJSON :: Interval -> Value Source # toEncoding :: Interval -> Encoding Source # toJSONList :: [Interval] -> Value Source # toEncodingList :: [Interval] -> Encoding Source # omitField :: Interval -> Bool Source #
ToJSON Journal Source # |
Instance details Methods toJSON :: Journal -> Value Source # toEncoding :: Journal -> Encoding Source # toJSONList :: [Journal] -> Value Source # toEncodingList :: [Journal] -> Encoding Source # omitField :: Journal -> Bool Source #
ToJSON Ledger Source # |
Instance details Methods toJSON :: Ledger -> Value Source # toEncoding :: Ledger -> Encoding Source # toJSONList :: [Ledger] -> Value Source # toEncodingList :: [Ledger] -> Encoding Source # omitField :: Ledger -> Bool Source #
ToJSON MarketPrice Source # |
Instance details Methods toJSON :: MarketPrice -> Value Source # toEncoding :: MarketPrice -> Encoding Source # toJSONList :: [MarketPrice] -> Value Source # toEncodingList :: [MarketPrice] -> Encoding Source # omitField :: MarketPrice -> Bool Source #
ToJSON MixedAmount Source # |
Instance details Methods toJSON :: MixedAmount -> Value Source # toEncoding :: MixedAmount -> Encoding Source # toJSONList :: [MixedAmount] -> Value Source # toEncodingList :: [MixedAmount] -> Encoding Source # omitField :: MixedAmount -> Bool Source #
ToJSON PayeeDeclarationInfo Source # |
Instance details Methods toJSON :: PayeeDeclarationInfo -> Value Source # toEncoding :: PayeeDeclarationInfo -> Encoding Source # toJSONList :: [PayeeDeclarationInfo] -> Value Source # toEncodingList :: [PayeeDeclarationInfo] -> Encoding Source # omitField :: PayeeDeclarationInfo -> Bool Source #
ToJSON Period Source # |
Instance details Methods toJSON :: Period -> Value Source # toEncoding :: Period -> Encoding Source # toJSONList :: [Period] -> Value Source # toEncodingList :: [Period] -> Encoding Source # omitField :: Period -> Bool Source #
ToJSON PeriodicTransaction Source # |
Instance details Methods toJSON :: PeriodicTransaction -> Value Source # toEncoding :: PeriodicTransaction -> Encoding Source # toJSONList :: [PeriodicTransaction] -> Value Source # toEncodingList :: [PeriodicTransaction] -> Encoding Source # omitField :: PeriodicTransaction -> Bool Source #
ToJSON Posting Source # |
Instance details Methods toJSON :: Posting -> Value Source # toEncoding :: Posting -> Encoding Source # toJSONList :: [Posting] -> Value Source # toEncodingList :: [Posting] -> Encoding Source # omitField :: Posting -> Bool Source #
ToJSON PostingType Source # |
Instance details Methods toJSON :: PostingType -> Value Source # toEncoding :: PostingType -> Encoding Source # toJSONList :: [PostingType] -> Value Source # toEncodingList :: [PostingType] -> Encoding Source # omitField :: PostingType -> Bool Source #
ToJSON PriceDirective Source # |
Instance details Methods toJSON :: PriceDirective -> Value Source # toEncoding :: PriceDirective -> Encoding Source # toJSONList :: [PriceDirective] -> Value Source # toEncodingList :: [PriceDirective] -> Encoding Source # omitField :: PriceDirective -> Bool Source #
ToJSON Rounding Source # |
Instance details Methods toJSON :: Rounding -> Value Source # toEncoding :: Rounding -> Encoding Source # toJSONList :: [Rounding] -> Value Source # toEncodingList :: [Rounding] -> Encoding Source # omitField :: Rounding -> Bool Source #
ToJSON Side Source # |
Instance details Methods toJSON :: Side -> Value Source # toEncoding :: Side -> Encoding Source # toJSONList :: [Side] -> Value Source # toEncodingList :: [Side] -> Encoding Source # omitField :: Side -> Bool Source #
ToJSON Status Source # |
Instance details Methods toJSON :: Status -> Value Source # toEncoding :: Status -> Encoding Source # toJSONList :: [Status] -> Value Source # toEncodingList :: [Status] -> Encoding Source # omitField :: Status -> Bool Source #
ToJSON TMPostingRule Source # |
Instance details Methods toJSON :: TMPostingRule -> Value Source # toEncoding :: TMPostingRule -> Encoding Source # toJSONList :: [TMPostingRule] -> Value Source # toEncodingList :: [TMPostingRule] -> Encoding Source # omitField :: TMPostingRule -> Bool Source #
ToJSON TagDeclarationInfo Source # |
Instance details Methods toJSON :: TagDeclarationInfo -> Value Source # toEncoding :: TagDeclarationInfo -> Encoding Source # toJSONList :: [TagDeclarationInfo] -> Value Source # toEncodingList :: [TagDeclarationInfo] -> Encoding Source # omitField :: TagDeclarationInfo -> Bool Source #
ToJSON TimeclockCode Source # |
Instance details Methods toJSON :: TimeclockCode -> Value Source # toEncoding :: TimeclockCode -> Encoding Source # toJSONList :: [TimeclockCode] -> Value Source # toEncodingList :: [TimeclockCode] -> Encoding Source # omitField :: TimeclockCode -> Bool Source #
ToJSON TimeclockEntry Source # |
Instance details Methods toJSON :: TimeclockEntry -> Value Source # toEncoding :: TimeclockEntry -> Encoding Source # toJSONList :: [TimeclockEntry] -> Value Source # toEncodingList :: [TimeclockEntry] -> Encoding Source # omitField :: TimeclockEntry -> Bool Source #
ToJSON Transaction Source # |
Instance details Methods toJSON :: Transaction -> Value Source # toEncoding :: Transaction -> Encoding Source # toJSONList :: [Transaction] -> Value Source # toEncodingList :: [Transaction] -> Encoding Source # omitField :: Transaction -> Bool Source #
ToJSON TransactionModifier Source # |
Instance details Methods toJSON :: TransactionModifier -> Value Source # toEncoding :: TransactionModifier -> Encoding Source # toJSONList :: [TransactionModifier] -> Value Source # toEncodingList :: [TransactionModifier] -> Encoding Source # omitField :: TransactionModifier -> Bool Source #
ToJSON Pos Source # |
Instance details Methods toJSON :: Pos -> Value Source # toEncoding :: Pos -> Encoding Source # toJSONList :: [Pos] -> Value Source # toEncodingList :: [Pos] -> Encoding Source # omitField :: Pos -> Bool Source #
ToJSON SourcePos Source # |
Instance details Methods toJSON :: SourcePos -> Value Source # toEncoding :: SourcePos -> Encoding Source # toJSONList :: [SourcePos] -> Value Source # toEncodingList :: [SourcePos] -> Encoding Source # omitField :: SourcePos -> Bool Source #
ToJSONKey AccountType Source # |
Instance details Methods toJSONKey :: ToJSONKeyFunction AccountType Source # toJSONKeyList :: ToJSONKeyFunction [AccountType] Source #
FromJSON (DecimalRaw Integer) Source # |
Instance details Methods parseJSON :: Value -> Parser (DecimalRaw Integer) Source # parseJSONList :: Value -> Parser [DecimalRaw Integer] Source # omittedField :: Maybe (DecimalRaw Integer) Source #
FromJSON a => FromJSON (Account a) Source # |
Instance details Methods parseJSON :: Value -> Parser (Account a) Source # parseJSONList :: Value -> Parser [Account a] Source # omittedField :: Maybe (Account a) Source #
FromJSON a => FromJSON (PeriodData a) Source # |
Instance details Methods parseJSON :: Value -> Parser (PeriodData a) Source # parseJSONList :: Value -> Parser [PeriodData a] Source # omittedField :: Maybe (PeriodData a) Source #
(Integral a, ToJSON a) => ToJSON (DecimalRaw a) Source # |
Instance details Methods toJSON :: DecimalRaw a -> Value Source # toEncoding :: DecimalRaw a -> Encoding Source # toJSONList :: [DecimalRaw a] -> Value Source # toEncodingList :: [DecimalRaw a] -> Encoding Source # omitField :: DecimalRaw a -> Bool Source #
ToJSON a => ToJSON (Account a) Source # |
Instance details Methods toJSON :: Account a -> Value Source # toEncoding :: Account a -> Encoding Source # toJSONList :: [Account a] -> Value Source # toEncodingList :: [Account a] -> Encoding Source # omitField :: Account a -> Bool Source #
ToJSON a => ToJSON (PeriodData a) Source # |
Instance details Methods toJSON :: PeriodData a -> Value Source # toEncoding :: PeriodData a -> Encoding Source # toJSONList :: [PeriodData a] -> Value Source # toEncodingList :: [PeriodData a] -> Encoding Source # omitField :: PeriodData a -> Bool Source #