piston-cli
piston-cli copied to clipboard
piston outputs invalid json
trafficstars
The docs suggest the following:
sneak@pris:~$ pip3 install steem-piston
Collecting steem-piston
....usw....
Installed fine. Testing, per the docs:
piston -x transfer --account xeroc fabian 0.001 SBD > unsigned-transaction.json
This outputs the following to unsigned-transaction.json:
{'blockchain': {'chain_id': '0000000000000000000000000000000000000000000000000000000000000000',
'core_symbol': 'STEEM',
'prefix': 'STM'},
'expiration': '2017-02-06T06:37:38',
'extensions': [],
'missing_signatures': ['STM6quoHiVnmiDEXyz4fAsrNd28G6q7qBCitWbZGo4pTfQn8SwkzD'],
'operations': [['transfer',
{'amount': '0.001 SBD',
'from': 'xeroc',
'memo': '',
'to': 'fabian'}]],
'ref_block_num': 14098,
'ref_block_prefix': 3767381196,
'required_authorities': {'xeroc': {'account_auths': [],
'key_auths': [['STM6quoHiVnmiDEXyz4fAsrNd28G6q7qBCitWbZGo4pTfQn8SwkzD',
1]],
'weight_threshold': 1}},
'signatures': []}
Then, trying to parse:
sneak@pris:~$ jq . unsigned-transaction.json
parse error: Invalid numeric literal at line 1, column 14
Turns out, json requires double quotes. Single-quoted keys and strings are invalid json.
Yhea .. it's not real json .. it is the output of pprint which just looks like json ...
I should probably change pprint and make it a print(json.dumps(x, indent=4))
In the meantime, you can still load the file into python using
with open(args.file) as fp:
tx = fp.read()
json_tx = eval(tx)