使用JavaScript解析JSON

 倒骑毛驴笑看人生gnWC_659 发布于 2022-12-21 09:26

也许有人可以帮我走正确的方向?非常感谢任何提示.

 var credentials = { steam: {}, rpc: {} };
 var rawCredentials = JSON.parse(fs.readFileSync("auth.json", { "encoding": "utf8" }));
 credentials.steam.accountName = rawCredentials.steam.accountName;
 credentials.steam.password = rawCredentials.steam.password;
 credentials.steam.shaSentryfile = new Buffer(rawCredentials.steam.shaSentryfile, "hex");
 credentials.rpc.username = rawCredentials.rpc.username;
 credentials.rpc.password = rawCredentials.rpc.password;

auth.json文件

 {
 "credentials.steam.accountName": "XXX",
 "credentials.steam.password": "XXX",
 }

无法读取未定义的属性"accountName"

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有