我会在 json 内部导航以解析 json'data'。我尝试使用 JSON Stringfy 但没有。例如,另一个我会导航内部数据以解析“hometeam”。感谢您最终的帮助
var TelegramBot = require ('node-telegram-bot-api');
var token = '********';
var bot = new TelegramBot(token, {polling:true});
var request = require('request');
const { parse } = require('path');
bot.on("polling_error", (err) => console.log(err));
bot.onText(/\/start/, function(msg, match) {
var chatId = msg.chat.id;
request('https://www.oddsmath.com/api/v1/dropping-odds.json/?language=en&timezone=Europe%2FRome&provider_id=32&country_code=IT&cat_id=0&interval=60&sortBy=1&time=24&limit=20', function(error,response,body){
if(!error && response.statusCode == 200){
bot.sendMessage(chatId, 'Looking for...', {parse_mode:'Markdown'})
.then(function(msg){
var res = JSON.parse(body);
var dat = res.data;
console.log(dat);
bot.sendMessage(chatId, 'Result:\n' + dat)
})
}
});
});
我正在解析的 JSON 看起来像这样
{
"3207031-0": {
"time": '2020-06-16 12:30:00',
"hometeam": "Regar-TadAZ Tursunzoda",
"awayteam": "FK Istiklol",
"league": "Tajikistan - National Football League"
},
{...}
}