Python中紧凑但漂亮的JSON输出?

sds*_*sds 5 python json pretty-print python-2.7

JSON的写法是indent=None(默认)作为单行(人眼无法读取),或者ident=N在每个逗号后都使用换行符。

我希望看到的是更紧凑但仍然很漂亮的输出,类似于Common Lisp漂亮的打印效果。例如,代替

 {
  "cleanup":{
   "cpu":6936.780000000001,
   "wall":7822.319401979446
  },
  "finished":"2017-08-14 18:36:23",
  "init":{
   "cpu":1365.73,
   "wall":1380.7802910804749
  },
  "job":"timings",
  "run":{
   "cpu":953.6700000000001,
   "wall":8350.496850013733
  },
  "started":"2017-08-14 13:28:06"
 }
Run Code Online (Sandbox Code Playgroud)

我想看看

 {
  "cleanup":{"cpu":6936.780000000001,"wall":7822.319401979446},
  "finished":"2017-08-14 18:36:23",
  "init":{"cpu":1365.73,"wall":1380.7802910804749},
  "job":"timings",
  "run":{"cpu":953.6700000000001,"wall":8350.496850013733},
  "started":"2017-08-14 13:28:06"
 }
Run Code Online (Sandbox Code Playgroud)

类似于pprint产生的东西。

sds*_*sds 2

目前这是不可能的,但是当实现RFE:更紧凑的漂亮打印时,这个问题将通过使用python-rapidjson得到回答。