我能够从azure函数中读取JSON文件,而且我还希望更新JSON文件,这是我尝试过的代码。
module.exports = async function (context, myTimer) {
var axios = require('axios')
var path = require('path')
var fs = require('fs')
var update_json = require('json-update')
var response = await axios.get('https://nseindia.com/live_market/dynaContent/live_watch/stock_watch/nifty500StockWatch.json')
await update_json.update('D:\home\site\wwwroot\TimerTrigger2\holiday.json',{'name':"jeeva"})
var data2 = await update_json.load('D:\home\site\wwwroot\TimerTrigger2\holiday.json')
context.log(data2.name)
context.log(typeof JSON.stringify(response['data']['data']))
context.log(typeof response['data']['data'])
return response['data']['data']
};
这是我的json文件。
{
"name":"saran"
}
这里我使用的是json-update包,我也同意其他一些包,我该怎么办?