@12d1212

Как достать нужные данные из UrlFetchApp или JSON.parse?

По логам данные выходят в таком формате, нужно достать
message_id=53204.0
{result={date=1.635769484E9, message_id=53204.0, from={first_name=IPhoшка [Инфобот], username=infoip4_bot, is_bot=true, id=2.09014609loE9}, , type=supergroup}}, ok=true}


идея была такая, но не сработало
var takeid = JSON.parse(UrlFetchApp.fetch('https://api.telegram.org/bot' + token + '/', data));
  var idString = takeid.toString();
  var start = 0;
  var searching = "message_id=" + start.toString() + ".0";
  while (idString.indexOf(searching!=-1)){
     start++
  }
  • Вопрос задан
  • 1499 просмотров
Пригласить эксперта
Ответы на вопрос 1
@LazuPastqs
Для моего кода выглядит следующем образом
var takeid = JSON.parse(UrlFetchApp.fetch(url, options));

console.log(takeid);

"{ HTP: { value: 0, diff: '65 → 65' },
  ORE: { value: 8.04, diff: '907.51 → 915.55' },
  RE: { value: 8.32, diff: '942.67 → 951' },
  WN6: { value: 11, diff: '889.13 → 900.13' },
  WN7: { value: 11, diff: '889.13 → 900.13' },
  WN8: { value: 20, diff: '1078 → 1098' },
  WN8KTTC: { value: 4, diff: '862 → 866' },
  BRON: { value: 70.76, diff: '3602.5 → 3673.27' },
  XVM: { value: 0.66, diff: '39.42 → 40.08' },
  WG: { value: 83, diff: '5622 → 5705' },
  PW: { value: 0.19, diff: '48.88 → 49.07' },
  DMG: { value: 15.41, diff: '1057.96 → 1073.37' },
  TNK: { value: 4.74, diff: '1141.5 → 1146.24' },
  EAV: { value: 7, diff: '556 → 563' },
  SPT: { value: 0.01, diff: '1.05 → 1.06' },
  DST: { value: 0.01, diff: '0.66 → 0.66' },
  CPT: { value: 0.01, diff: '0.71 → 0.71' },
  DEF: { value: 0, diff: '0.46 → 0.45' },
  LIV: { value: 0.04, diff: '21.93 → 21.96' },
  KDES: { value: 0.01, diff: '0.84 → 0.85' } }"

console.log(takeid.HTP);
"{ value: 0, diff: '65 → 65' }"


console.log(takeid.HTP.value);
"0"
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы