Closed MarcinOrlowski closed 5 years ago
Can you show a bit of code to illustrate how you are dumping both?
While I do have some yaml loading/dumping in the code, I haven't tested with json loading/dumping so far. The yaml examples can be found here, they're used by the test system: https://github.com/WoLpH/mt940/blob/develop/tests/test_sta_parsing.py#L30-L39
My guess would be that the easiest way to get it working is by overriding JSONEncoder.default
to support these types: https://docs.python.org/3/library/json.html#json.JSONEncoder.default
I am using examples from README. Literally as-is.
You're right. That demo is lacking quite a bit. I've updated the code in the readme to be a bit more useful :)
Does that help?
Thanks. No, it's still not work properly as all the dates (date
, entry_date
, guessed_entry_date
) values are not in JSON dump.
I've created a json encoder which should handle all of the types for you. That should help a bit :)
import json
import mt940
transactions = mt940.parse('tests/jejik/abnamro.sta')
print(json.dumps(transactions, indent=4, cls=mt940.JSONEncoder))
That works perfect. Thank you!
I am trying to parse my bank's MT940 data with your library and example of JSON encoding is producing different results than "plain" data dump. This is what I see with plain dump:
and this is what JSON dump example outputs:
And relevant part of the source file: