weixin_33717298
2019-11-15 19:28
采纳率: 0%
浏览 33

如何使用jQuery做到这一点

So I have a list of items here :

347366834 AceofSpades
460724140   TheJadeRabbit
814876685   TrinityGhoul
1345867570  SweetBusiness
1508896098  TheWardcliffCoil
1852863732  Wavesplitter
2044500762  TheQueenbreaker
2146650065  PrometheusLens
2694576561  Two-TailedFox
2896466320  TheJadeRabbit
3141979346  DARCI
2978016230  TheJadeRabbit
3229272315  TheJadeRabbit
3413860062  TheChaperone
3512014804  Lumina
3580904580  LegendofAcrius
3628991658  GravitonLance
3844694310  TheJadeRabbit
4036115577  SleeperSimulant
4255268456  Skyburner'sOath
4190156464  Merciless
3973202132  Thorn
3588934839  LeMonarque
3766045777  BlackTalon
3549153979  TheProspector
3437746471  Crimson
3141979347  Borealis
3413074534  PolarisLance
3211806999  Izanagi'sBurden
3110698812  Tarrabah
2907129557  Sunshot
2130065553  Arbalest
1891561814  WhisperoftheWorm
1744115122  LegendofAcrius
1364093401  TheLastWord
1331482397  MIDAMulti-Tool
814876684   Wish-Ender
417164956   Jötunn
204878059   Malfeasance
19024058    PrometheusLens
546372301   TheJadeRabbit
400096939   OutbreakPerfected
1201830623  Truth
1345867571  Coldheart
1541131350  Cerberus+1
1864563948  WorldlineZero
2069224589  OneThousandVoices
2816212794  BadJuju
3089417789  Riskrunner
3325463374  Thunderlord
2907129556  Sturm
3413860063  LordofWolves
3549153978  FightingLion
3580904581  TractorCannon
3628991659  VigilanceWing

This list is a list of item hashes from Destiny 2 api, as well as the names that correlate them.

If I make the ajax request

https://www.bungie.net/Platform/Destiny2/2/Account/4611686018472217782/Character/0/Stats/UniqueWeapons/

It gives me the Id's but not the names. My question is, is there a way for me to use jQuery to take the response which looks like this:

"Response": {
  "weapons": [{
        "referenceId": 2208405142,
        "values": {
          "uniqueWeaponAssists": {
            "statId": "uniqueWeaponAssists",
            "basic": {
              "value": 0.0,
              "displayValue": "0"
            }
          },
          "uniqueWeaponAssistDamage": {
            "statId": "uniqueWeaponAssistDamage",
            "basic": {
              "value": 0.0,
              "displayValue": "0"
            }
          },
          "uniqueWeaponKills": {
            "statId": "uniqueWeaponKills",
            "basic": {
              "value": 2069.0,
              "displayValue": "2069"
            }
          },
          "uniqueWeaponPrecisionKills": {
            "statId": "uniqueWeaponPrecisionKills",
            "basic": {
              "value": 0.0,
              "displayValue": "0"
            }
          },
          "uniqueWeaponKillsPrecisionKills": {
            "statId": "uniqueWeaponKillsPrecisionKills",
            "basic": {
              "value": 0.0,
              "displayValue": "0%"
            }
          }
        }
      },
      {
        "referenceId": 2286143274,
        "values": {
          "uniqueWeaponAssists": {
            "statId": "uniqueWeaponAssists",
            "basic": {
              "value": 0.0,
              "displayValue": "0"
            }
          },
          "uniqueWeaponAssistDamage": {
            "statId": "uniqueWeaponAssistDamage",
            "basic": {
              "value": 0.0,
              "displayValue": "0"
            }
          },
          "uniqueWeaponKills": {
            "statId": "uniqueWeaponKills",
            "basic": {
              "value": 1529.0,
              "displayValue": "1529"
            }
          },
          "uniqueWeaponPrecisionKills": {
            "statId": "uniqueWeaponPrecisionKills",
            "basic": {
              "value": 532.0,
              "displayValue": "532"
            }
          },
          "uniqueWeaponKillsPrecisionKills": {
            "statId": "uniqueWeaponKillsPrecisionKills",
            "basic": {
              "value": 0.34793982995421846,
              "displayValue": "35%"
            }
          }
        }
      },

to have it where jQuery takes the response and pairs it with the proper name where in the end I would have 2 objects (more objects going down such as weapontwo weaponthree ect).

weaponOneName = response.weapons.referenceid,
weaponOneValue = response.weapons.uniqueWeaponKills;

My thought was:

if response.weapons.referenceId = 3973202132 then referenceid = thorn 

or something similar

1条回答 默认 最新

相关推荐 更多相似问题