My code is:
import json
import cozmo
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
def getinfo():
rpc_connection = AuthServiceProxy("http://%s:%[email protected]:22225"%("user", "pass"))
print(rpc_connection.getinfo())
data = json.loads(getinfo())
jtopy=json.dumps(data)
dict_json=json.loads(jtopy)
print(dict_json)
#def cozmosay(robot: cozmo.robot.Robot):
# robot.say_text(getinfo).wait_for_completed()
#
#cozmo.run_program(cozmosay)
The code should return "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications" as the full string is { "version": 1150100, "protocolversion": 70015, "walletversion": 60000, "balance": 94356667.32563662, "blocks": 133199, "timeoffset": 0, "connections": 4, "proxy": "", "difficulty": 11.30994666912951, "testnet": false, "keypoololdest": 1637356708, "keypoolsize": 692, "paytxfee": 0.00000000, "relayfee": 0.00100000, "errors": "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications" }
but I get this error:
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
CodePudding user response:
Currently, getinfo() has no return statement so it returns NoneType. You should use return instead of print the data only.