为什么我的JSON解析不返回'/'符号?

时间:2015-06-12 15:15:55

标签: javascript json parsing

我认为这会很简单,但这是我第一次创建自己的JSON文件并进行解析。我有对象<和属性game路径将指向文件位置,但由于某种原因,解析返回一个没有正斜杠的字符串。我应该做些什么?

JSON代码:

game.path.

JS解析:

{
  "games": [
    {
      "game_title": "Skyrim",
      "game_series_name": "The Elder Scrolls",
      "game_series_sequence": "5",
      "game_path": "",
      "game_still_path": "StartScreens/Skyrim/maxresdefault.jpg"
    }
  ]
}

HTML中的结果:

$(document).ready(function(){
  $.getJSON('screens.json', function(data) {
    var output ='';
    for(var i in data.games){
      output+= '<div class="col-lg-2 game-item" ';
      output+= 'style="background-image:"' + data.games[i].game_still_path + '"';
      output+= ' data-game-title="' + data.games[i].game_title + '"';
      output+= ' data-game-series-name="' + data.games[i].game_series_name + '"';
      output+= ' data-game-series-sequence="' + data.games[i].game_series_sequence + '"';
      output+= ' data-game-path="' + data.games[i].game_path + '"></div>';
      output+= '</div>';
    }
    $("#games-row").append(output);
  });
});

0 个答案:

没有答案