How to take time out from JSON?

  • 0
    I have 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"
      }


    How do I take "LyricDuration" from it and use it in setTimeout ()?

    Like to be something like this:
    setTimeout (function, LyricDuration) To take the value from LyricDuration and insert into setTimout ()?
    JavaScript Penelope Johnston, Nov 30, 2020

  • 2 Answers
  • 0
    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
    Hanna Shelton

  • 0

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!