小编iFl*_*ion的帖子

如何读取/写入 node.js 中的 JSON 文件

我对 node.js 相当陌生,我想知道如何(或什至是否)我可以读写 JSON 文件。我正在尝试创建一个可访问的惩罚历史。理想情况下,我希望能够按照以下方式创建一些东西:

{
"punishments": {
    "users": {
      "<example user who has a punishment history>": {
        "punishment-1567346": {
          "punishment-id": "1567346",
          "punishment-type": "mute",
          "punishment-reason": "<reason>"
        },
        "punishment-1567347": {
          "punishment-id": "1567347",
          "punishment-type": "ban",
          "punishment-reason": "<reason>"
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

然后我将有办法访问格式化的惩罚历史记录。我真的不知道从哪里开始。

javascript json read-write

1
推荐指数
1
解决办法
2074
查看次数

标签 统计

javascript ×1

json ×1

read-write ×1