使用jQuery读取Import.io生成的JSON(访问名称中带有斜杠的键)

使用jQuery读取Import.io生成的JSON(访问名称中带有斜杠的键),jquery,json,import.io,Jquery,Json,Import.io,我在访问某个值时遇到困难,因为它的键名称中包含正斜杠 以下是Import.io返回的JSON摘录: "results":[ { "superawesome_link":"https://medium.com/@sprawsmdoo", "graf_image":"https://cdn-images-1.medium.com/fit/t/800/240/1*YIWxXylsoUQIDfQK353YuA.png", "avatar_link":"https

我在访问某个值时遇到困难,因为它的键名称中包含正斜杠

以下是Import.io返回的JSON摘录:

"results":[  
  {  
     "superawesome_link":"https://medium.com/@sprawsmdoo",
     "graf_image":"https://cdn-images-1.medium.com/fit/t/800/240/1*YIWxXylsoUQIDfQK353YuA.png",
     "avatar_link":"https://medium.com/@sprawsmdoo",
     "darken_link/_text":"Jan 28",
     "readmore_number":10.0,
     "readmore_number/_source":"10",
     "readingtime_value_numbers/_source":"7",
     "readmore_link":"https://medium.com/@sprawsmdoo/pricing-design-services-bca1c6955b47?source=latest---------1",
     "readingtime_value_numbers":7.0,
     "readmore_link/_text":"Read more…",
     "darken_link":"https://medium.com/@sprawsmdoo/pricing-design-services-bca1c6955b47?source=latest---------1",
     "postarticle_link/_text":"Pricing design servicesWhat we’re doing, how we’re doing it, and what we’re struggling with when it…",
     "readingtime_value":"7 min read",
     "postarticle_link":"https://medium.com/@sprawsmdoo/pricing-design-services-bca1c6955b47?source=latest---------1",
     "superawesome_link/_text":"Superawesome"
  },
...
下面是我用来访问数据的jQuery代码:

var mediumJSON = "URLHERE";

$.ajax({
  url: mediumJSON,
  crossDomain: true,
  dataType: 'json',
  success: function(response) {
    $.each(response.results, function(index, value) {
      var newPost = $("#postTemplate").clone();
      newPost.appendTo('.posts');
      newPost.removeAttr('id');
      newPost.find('.post-title a').attr('href', value.readmore_link).text(value.postarticle_link/text);
      newPost.find('.post-length').text(value.readingtime_value);
      newPost.show();
      return index < 4;
    });
  },
  error: function(jqXHR, textStatus, errorThrown) {
    $('.posts').html('<article class="post"><div class="quiet">There was an error fetching posts, you can read our blog <a href="https://medium.com/@sprawsmdoo">directly on Medium</a>.</div></article>');
  }
});
错误消息为“未捕获引用错误:未定义文本”

如何引用
postarticle\u link/text
以获取其值?

您需要使用它,它允许访问包含特殊字符的属性

var数据={
“readmore_编号”:10.0,
“readmore\u number/\u source”:“10”,
“superawesome_链接/_文本”:“superawesome”
}

警报(数据['superawesome\u link/\u text'])
似乎您使用了import.io的“魔力”。您可以简单地使用它们并构建一个新的提取器。通过这种方式,您可以指向并单击所需的数据,更改数据类型(链接或文本),并为生成的数据列指定所需的名称(不带斜杠)

.text(value.postarticle_link/text)