I'm trying to convert a python dictionary to the target
JSON object below. I figured I'd use json.dumps()
(as per this thread) but the result is not the same nevertheless. The target
has some unconvential spacing in it, but I'm not allowed to change it or edit them out.
Any idea how to approach this?
import json
dict= {"token":{"name":"John Doe","code":"123456789"}}
target = '{ "token":{ "name":"John Doe", "code":"123456789" } }'
print(json.dumps(dict))
print(json.loads(json.dumps(dict)))
print(target)
>>>{"token": {"name": "John Doe", "code": "123456789"}}
>>>{'token': {'name': 'John Doe', 'code': '123456789'}}
>>>{ "token":{ "name":"John Doe", "code":"123456789" } }
For additional context, I'm trying to prepare the argument passed through Bambora's payment API. See the cURL example associated to this here.