哪个具有更好的性能,可以通过JSON.stringify保存对文本的其余响应或将响应转换为文本?

我正在从木偶响应侦听器中将数百万个json对象保存到文本文件中。哪个选项具有更好的性能,并被视为最佳实践。

选项1-带有JSON.stringify

//puppeteer listener
page.on("response",async response => {

   let jsonResponse = await response.json();

   await fs.writeFileSync(
      "1.json",JSON.stringify(jsonResponse)
   );

})

选项2-将响应转换为文本

page.on("response",async response => {

   let jsonTextResponse = await response.text();

   await fs.writeFileSync(
      "2.json",jsonTextResponse
   );

})
Foxronger 回答:哪个具有更好的性能,可以通过JSON.stringify保存对文本的其余响应或将响应转换为文本?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3170143.html

大家都在问