Benjamin-Loison / cpython

The Python programming language
https://www.python.org/
Other
0 stars 0 forks source link

How to `json.dumps(data, indent = 4)` with `'` instead of `"`? #16

Open Benjamin-Loison opened 7 months ago

Benjamin-Loison commented 7 months ago

https://stackoverflow.com/q/4162642

ast.literal_eval does not have the indent = 4 aspect, as it returns:

{'2': {'type': 'message', 'message_typedef': {'2': {'type': 'int'}}, 'field_order': [('2', 0)]}}

pprint.pprint(data) (and indent = 4) does not seem to help, as it returns:

{'2': {'field_order': [('2', 0)],
       'message_typedef': {'2': {'type': 'int'}},
       'type': 'message'}}