diff options
author | Harald Welte <laforge@osmocom.org> | 2021-04-10 17:18:17 +0200 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2021-04-10 18:41:15 +0200 |
commit | 5e749a79ac5c783089154d4397478652cc7f0b23 (patch) | |
tree | 3554fb5abfbf444f66c70ddd2aa4f5631b51f48f /pySim-shell.py | |
parent | 7829d8a3579f196fc78f87e5a3de0214f22f6fb3 (diff) |
extend JSONEncoder to serialze 'bytes' style objects as hex strings
This means we can skip a lot of code that manually converts from
bytes to hex before JSON serialization.
Change-Id: I9c9eff0556d9d196e64553b5276e162f69d0c18f
Diffstat (limited to 'pySim-shell.py')
-rwxr-xr-x | pySim-shell.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pySim-shell.py b/pySim-shell.py index ce1b3bf..1d81eb8 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -39,7 +39,7 @@ from pySim.exceptions import * from pySim.commands import SimCardCommands from pySim.transport import init_reader, ApduTracer from pySim.cards import card_detect, Card -from pySim.utils import h2b, swap_nibbles, rpad, h2s +from pySim.utils import h2b, swap_nibbles, rpad, h2s, JsonEncoder from pySim.utils import dec_st, sanitize_pin_adm, tabulate_str_list, is_hex from pySim.card_handler import card_handler @@ -81,9 +81,9 @@ class PysimApp(cmd2.Cmd): def poutput_json(self, data, force_no_pretty = False): """line cmd2.putput() but for a json serializable dict.""" if force_no_pretty or self.json_pretty_print == False: - output = json.dumps(data) + output = json.dumps(data, cls=JsonEncoder) else: - output = json.dumps(data, indent=4) + output = json.dumps(data, cls=JsonEncoder, indent=4) self.poutput(output) def _onchange_numeric_path(self, param_name, old, new): |