output hex strings in JSON rather than numbers

Apparently the precise precision JavaScript has for storing integers may not
quite be enough. We push this problem downstream by saving the hexadecimal
representation of the key rather than the number itself.
This commit is contained in:
Rich Wareham
2010-09-17 12:41:26 +01:00
parent 0da34485b6
commit fccbdf1e7c

View File

@@ -179,8 +179,10 @@ def output_json(ksv, key, is_sink):
The KSV is a single integer. The key is a list of 40 integers."""
print(json.dumps(
{ 'ksv': ksv, 'key': key, 'type': 'sink' if is_sink else 'source' },
print(json.dumps( {
'ksv': ('%010x' % ksv),
'key': map(lambda x: '%014x' % x, key),
'type': 'sink' if is_sink else 'source' },
sort_keys=True, indent=True))
# run the 'main' function if this file is being executed directly