我有一个创建json的python脚本,还有一个读取json的nodejs脚本:
with open("music.json", "w") as write_file:
json.dump(music_found, write_file, indent=4)
找到的音乐是一个对象数组
import fs from 'fs'
import { cwd } from 'process';
let rawdata = fs.readFileSync(`${cwd()}/music.json`);
let music = JSON.parse(rawdata)
console.log(music);
我收到消息json输入意外结束
[
{
"user": "some_user1",
"file": "@@enlbq\\_Music\\Infected Mushroom\\Return to the Sauce [2017] [HMCD94]\\09 - Infected Mushroom - Liquid Smoke.flac",
"size": 42084572,
"slots": true,
"speed": 1003176
},
{
"user": "some_user2",
"file": "@@xfjpb\\Musiikkia\\Infected Mushroom\\Return to the Sauce\\09 Infected Mushroom - Liquid Smoke.flac",
"size": 24617421,
"slots": true,
"speed": 541950
},
{
"user": "some_user3",
"file": "@@rxjpv\\MyMusic\\Infected Mushroom\\Infected Mushroom - Return To The Sauce (2017) [CD FLAC]\\09 - Liquid Smoke.flac",
"size": 41769608,
"slots": true,
"speed": 451671
}
]
我的json格式很好不是吗?我从4小时起就在这上面了,我一直在这上面。。。非常烦人^^希望有人能帮忙
你能确定路径是正确的吗? 我可以在js中正常读取您的数据,所以我认为问题在于路径
readFileSync
您需要设置编码或使用缓冲区的.toString(方法
相关问题 更多 >
编程相关推荐