weixin_33725270 2019-11-19 17:53 采纳率: 0%
浏览 25

使用ajax的Jsonpath问题

Here I have a code that for some reason Does not pop up any errors but it also does not do what I want it to do which is pull up a list of all the reference Id's from this json file

$(function() {

  {
    $.ajax({
      url: "https://www.bungie.net/Platform/Destiny2/2/Account/4611686018429000034/Character/0/Stats/UniqueWeapons/",
      headers: {
        "X-API-Key": apiKey
      },
      success: function(data) {
        let
          NameT = jsonPath("$.Response..referenceId");
        $('#player-NameT').text(NameT);

        console.log(NameT);

      },

    });
  }
});

here is the json data

{
    "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": 1117.0,
                            "displayValue": "1117"
                        }
                    },
                    "uniqueWeaponPrecisionKills": {
                        "statId": "uniqueWeaponPrecisionKills",
                        "basic": {
                            "value": 1.0,
                            "displayValue": "1"
                        }
                    },
                    "uniqueWeaponKillsPrecisionKills": {
                        "statId": "uniqueWeaponKillsPrecisionKills",
                        "basic": {
                            "value": 0.00089525514771709937,
                            "displayValue": "0%"
                        }
                    }
                }
            },
            {
                "referenceId": 2232171099,
                "values": {
                    "uniqueWeaponAssists": {
                        "statId": "uniqueWeaponAssists",
                        "basic": {
                            "value": 0.0,
                  

I added the json data in here .
It is only a sample of it as the full amount it over 79k characters .

  • 写回答

2条回答 默认 最新

  • weixin_33694172 2019-11-19 18:04
    关注

    I Hope this might will help you. Can you please also share your JSON response in which you are getting an error response.

    $(function() {
    
    {
    $.ajax({
      dataType: "json",
      url: "https://www.bungie.net/Platform/Destiny2/2/Account/4611686018429000034/Character/0/Stats/UniqueWeapons/",
      headers: {
        "X-API-Key": apiKey
      },
      success: function(data) {
          var weaponCollection = $.parseJSON(data);
          if( weaponCollection.length != 0 ){
              console.log(weaponCollection.Response.weapons);
          }  
      },
      complete: function(data){
        console.log(data);
      },
      error: function(error){
        console.log("Error:");
      }
    });
    }
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器