Как взять тайм из JSON?

У меня есть JSON:
{
  "MapName": "Adeyyo",
  "JDVersion": 2019,
  "OriginalJDVersion": 2019,
  "Artist": "Ece Seçkin",
  "Title": "Adeyyo",
  "Credits": "Written by Aysen Şimşekyay, Kemal Şimşekyay and arranged by Ozan Doğulu. Published by DMC & PRM. Courtesy of DGL. All rights of the producer and other rightholders to the recorded work reserved. Unless otherwise authorized, the duplication, rental, loan, exchange or use of this video game for public performance, broadcasting and online distribution to the public are prohibited.",
  "NumCoach": 1,
  "BannerVideo": 0,
  "CoachBeat": 1210,
  "OnlineMap": 0,
  "Tags": [
  "main"
  ],
  "PictogramBar": 1,
  "PictoDuration": 3000,
  "BeatDuration": 3000,
  "LyricDuration": 1750,
  "PictoResolutionX": 256,
  "PictoResolutionY": 256,
  "PictoResolutionUHD": 0,
  "VideoType": "mp4",
  "AudioType": "ogg",
  "LyricColors": [111, 255, 182],
  "LyricSpeed": 100,
  "goldmoves": [166105,  226105],
  "Difficulty": 1,
  "DefaultColors": {
    "lyrics": "0xFF6FFFB6",
    "theme": "0xFFFFFFFF",
    "songColor_1A": "0xFF010342",
    "songColor_1B": "0xFF411554",
    "songColor_2A": "0xFF97FAFC",
    "songColor_2B": "0xFF11B7C6"
  }


Как мне взять из него "LyricDuration" и использовать в setTimeout()?

Типо чтобы было как-то так:
setTimeout(function, LyricDuration) Чтобы бралось значение из LyricDuration и вставлялось в setTimout() ?
  • Вопрос задан
  • 97 просмотров
Решения вопроса 2
Alexandre888
@Alexandre888
Javascript-разработчик
var obj = {
  "MapName": "Adeyyo",
  "JDVersion": 2019,
  "OriginalJDVersion": 2019,
  "Artist": "Ece Seçkin",
  "Title": "Adeyyo",
  "Credits": "Written by Aysen Şimşekyay, Kemal Şimşekyay and arranged by Ozan Doğulu. Published by DMC & PRM. Courtesy of DGL. All rights of the producer and other rightholders to the recorded work reserved. Unless otherwise authorized, the duplication, rental, loan, exchange or use of this video game for public performance, broadcasting and online distribution to the public are prohibited.",
  "NumCoach": 1,
  "BannerVideo": 0,
  "CoachBeat": 1210,
  "OnlineMap": 0,
  "Tags": [
    "main"
  ],
  "PictogramBar": 1,
  "PictoDuration": 3000,
  "BeatDuration": 3000,
  "LyricDuration": 1750,
  "PictoResolutionX": 256,
  "PictoResolutionY": 256,
  "PictoResolutionUHD": 0,
  "VideoType": "mp4",
  "AudioType": "ogg",
  "LyricColors": [111, 255, 182],
  "LyricSpeed": 100,
  "goldmoves": [166105, 226105],
  "Difficulty": 1,
  "DefaultColors": {
    "lyrics": "0xFF6FFFB6",
    "theme": "0xFFFFFFFF",
    "songColor_1A": "0xFF010342",
    "songColor_1B": "0xFF411554",
    "songColor_2A": "0xFF97FAFC",
    "songColor_2B": "0xFF11B7C6"
  }
}

var value = 0;

for (let key in obj) {
	if (key === "LyricDuration") value += obj[key]
}

// value === 1750
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

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

Войти через центр авторизации
Похожие вопросы