fork(4) download
  1. json = '''{
  2. "a": {
  3. "x":1,
  4. "y":2
  5. },
  6. "b": {
  7. "z":3,
  8. "w":4
  9. }
  10. "c": [1, 2, 3]
  11. }'''
  12.  
  13. import re
  14. better_json = re.sub(r'^((\s*)".*?":)\s*([\[{])', r'\1\n\2\3', json, flags=re.MULTILINE)
  15. print(better_json)
Success #stdin #stdout 0.02s 28384KB
stdin
Standard input is empty
stdout
{
    "a":
    {
        "x":1,
        "y":2
    },
    "b":
    {
        "z":3,
        "w":4
    }
    "c":
    [1, 2, 3]
}