ファイル構造図
{ " 次":" b.json " 、 " MSG ":" これは" }
{ " 次":" c.json " 、 " MSG ":" これはBです" }
{ " 次へ":" ヌル" 、 " MSG ":" これはCです" }
1つ上のレベル
CONST FS =(必要' FSを' ) CONST =パス(必要' パス' ) // jpromiseでファイルの内容を取得 関数getFileContent(filName){ constの 約束= 新しい約束((解決、拒否)=> { constの fullFileName = path.resolve(__ dirnameは、' ファイル' 、filName) fs.readFile(fullFileName、(ERR、データ) => { もし(ERR){ 拒否(ERR) リターン } 決意( JSON.parse(data.toString()) ) }) }) リターンの約束 } getFileContent(' a.json ').then(ADATA => { console.log(" データ" 、ADATA) リターンgetFileContent(aData.next) })。次に、(BDATA => { console.log(" Bデータ" 、BDATA) リターンgetFileContent(bData.next) })。次に、(CDATA => { console.log(" Cデータ" 、CDATA) })