0

倾倒hjson

您好,我有一个如下所示的 json:

{
  //yee
  "ea": "sports", # sheesh
}

我的 py 看起来像这样:

import hjson

with open("generator.json") as file:
    content = hjson.load(file)

content["test"] = "ea"

with open("generator.json", "w") as file:
    content = hjson.dumps(content, file)

但是现在,json看起来像

{
  "ea": "sports",
  "test": "ea"
}

即使我想要

{
  //yee
  "ea": "sports", # sheesh
  "test": "ea"
}

我怎样才能做到这一点?

4

0 回答 0