我该如何在Node.js中将字符串数组保存到
JSON
文件中?const alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];
example.json
[
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h"
]
JSON.stringify
将 JSON 对象转换为字符串 (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)。 - msbit