hledger/hledger/test/json.test
Stephen Morgan a529207ae7 lib: Do not round Decimal before applying JSON representation if
existing representation is small enough.

Previously the JSON representation of Decimal was rounded to 10 points
of precision before serialising. This sometimes results in an
unnecessary increase of precision.
2021-04-10 17:52:33 -10:00

116 lines
3.1 KiB
Plaintext

<
2019-1-1
(a) 1.0 AAA
# 1. Test the json output for register reports
$ hledger -f- reg --output-format=json
[
[
"2019-01-01",
null,
"",
{
"pbalanceassertion": null,
"pstatus": "Unmarked",
"pamount": [
{
"aprice": null,
"acommodity": "AAA",
"aquantity": {
"floatingPoint": 1,
"decimalPlaces": 1,
"decimalMantissa": 10
},
"aismultiplier": false,
"astyle": {
"ascommodityside": "R",
"asdigitgroups": null,
"ascommodityspaced": true,
"asprecision": 1,
"asdecimalpoint": "."
}
}
],
"ptransaction_": "1",
"paccount": "a",
"pdate": null,
"ptype": "VirtualPosting",
"pcomment": "",
"pdate2": null,
"ptags": [],
"poriginal": null
},
[
{
"aprice": null,
"acommodity": "AAA",
"aquantity": {
"floatingPoint": 1,
"decimalPlaces": 1,
"decimalMantissa": 10
},
"aismultiplier": false,
"astyle": {
"ascommodityside": "R",
"asdigitgroups": null,
"ascommodityspaced": true,
"asprecision": 1,
"asdecimalpoint": "."
}
}
]
]
]
# 2. Test the json output for balance reports
$ hledger -f- bal --output-format=json
[
[
[
"a",
"a",
0,
[
{
"aprice": null,
"acommodity": "AAA",
"aquantity": {
"floatingPoint": 1,
"decimalPlaces": 1,
"decimalMantissa": 10
},
"aismultiplier": false,
"astyle": {
"ascommodityside": "R",
"asdigitgroups": null,
"ascommodityspaced": true,
"asprecision": 1,
"asdecimalpoint": "."
}
}
]
]
],
[
{
"aprice": null,
"acommodity": "AAA",
"aquantity": {
"floatingPoint": 1,
"decimalPlaces": 1,
"decimalMantissa": 10
},
"aismultiplier": false,
"astyle": {
"ascommodityside": "R",
"asdigitgroups": null,
"ascommodityspaced": true,
"asprecision": 1,
"asdecimalpoint": "."
}
}
]
]
>=0