JSON file :
{"items": [ {"item1": "/xyz" }, {"item2": "/yzx" }, {"item3": "/zxy" } ]}
Python Code :
def funct(request): input = '' # Request body data = maybe_str(request.data()) if data: if is_json(request.headers.get('Content-Type', '')): input = json.dumps(data, indent=2, sort_keys=True, separators=(',', ': ')) else: input = data return input
The python function returns a formatted string and then places it within Sphinx CodeBlock.
Output :
{ "items": [ { "item1": "/xyz", "item2": "/yzx", "item3": "/zxy" }, { "item1": "/xyz", "item2": "/yzx", "item3": "/zxy" } ] }
Desired Output:
{"items": [ {"item1": "/xyz","item2": "/yzx","item3": "/zxy" }, {"item1": "/xyz","item2": "/yzx","item3": "/zxy" } ]}
I tried using .replace('\\n','\n')
from this stackoverflow issue but still didnt work.