Fixing traceback caused by incorrect argument passing to json.dumps

Fixes #5756