Reputation: 110382
I need to format something in this exact JSON format:
JSON.stringify(data,null,'\t');
How would I do this in python?
Upvotes: 1
Views: 2970
Reputation: 298392
For Python 3:
import json
json.dumps(data, indent='\t')
If you're using Python 2 or need to support both versions, use the simplejson
module:
import simplejson as json
The builtin json
module in Python 2 indents only with spaces.
Upvotes: 1