将大的JSONstring从NodeJS发送到Python

我需要从Node发送一个大的JSON文件到Python。 我可以用spawn来创buildchild_process来调用Python文件,但是我不知道如何将数据发送给它。 我试过使用pipe道,但我不理解文档。

码:

var dataset = JSON.stringify(doc.data); // Call the python API try { var py = require('child_process').spawn('python3', ['api.py', analysis, input]); } catch(error) { console.log(error); } // Pipe the data to the Python module py.stdin.pipe(fs.createWriteStream(dataset)); py.stdin.end(); 

错误:

 Uncaught Error: ENAMETOOLONG: name too long, open [file data printed to console here] 

这是一个很好的指导你正在做什么!

看起来像你也应该做py.stdin.write('json data');